Sign in to follow this  
Followers 0
wolf9228

Save function using C++ language

13 posts in this topic

#1 ·  Posted (edited)

SaveFunc
SaveFunc.zip

Save function using C++ language and then called the function using Autoit language

In the function of C++ language should not be used specifically in the input data
should not be used external pointer and the new operation

You must use the String as a C++ function

It should also be a C++ function stand-alone

Save Function can be called using the DllCallAddress function

ThreadDownload.au3

#include <WinAPI.au3>
#include <Memory.au3>
#include <ProgressConstants.au3>
#Include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include "GUICtrlSetOnEventEx.au3"
Global $Kernel32M = _WinAPI_LoadLibrary("Kernel32.dll")
Global $Kernel32O = DllOpen("Kernel32.dll"),$hMemFunc = 0,$hMemParams = 0
Global $GetAddressFuncReg = DllCallbackRegister("GetAddressFunc","ptr","int")

Global $Array , $complete = 1
$controlID1 = DownloaderMultiFiles($Array,"http://www.swfmax.com/get/SWF.max.exe",@ScriptDir & "\Dir1\SWF.max.exe")
GUICtrlSetOnEventEx($controlID1,$BN_CLICKED,"Clicked_Pause_Buttons")
GUICtrlSetOnEventEx($controlID1 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons")
$controlID2 = DownloaderMultiFiles($Array,"http://download.winzip.com/winzip150.exe",@ScriptDir & "\Dir1\winzip150.exe")
GUICtrlSetOnEventEx($controlID2,$BN_CLICKED,"Clicked_Pause_Buttons")
GUICtrlSetOnEventEx($controlID2 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons")
$controlID3 = DownloaderMultiFiles($Array,"http://www.flash-swf-converter.com/downloads/swfconverter.exe","",2)
GUICtrlSetOnEventEx($controlID3,$BN_CLICKED,"Clicked_Pause_Buttons")
GUICtrlSetOnEventEx($controlID3 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons")
$controlID4 = DownloaderMultiFiles($Array,"http://www.win-rar.com/fileadmin/winrar-versions/wrar420.exe",@ScriptDir & "\Dir2\wrar420.exe")
GUICtrlSetOnEventEx($controlID4,$BN_CLICKED,"Clicked_Pause_Buttons")
GUICtrlSetOnEventEx($controlID4 + 1,$BN_CLICKED,"Clicked_Cancel_Buttons")
While 1
if ($complete = 1)  Then
$complete = ProgressLoop($Array)
Else
MsgBox(0,"","download is complete")
Exit
EndIf
WEnd
Func Clicked_Pause_Buttons($ControlID,$NotificationCode)
$WPARAM = OnEventExGetWParam($ControlID,$NotificationCode)
$LPARAM = OnEventExGetLParam($ControlID,$NotificationCode)
$HWND = OnEventExGetHWND($ControlID,$NotificationCode)
For $i = 0 To UBound($Array) - 1
if $ControlID = $Array[$i][5] Then ExitLoop
Next
$Array[$i][9] = Not $Array[$i][9]
if ($Array[$i][9]) Then
GUICtrlSetData($ControlID,"Reset")
Else
GUICtrlSetData($ControlID,"Pause")
EndIf
$DownlHandle = EnvGet($ControlID)
PauseDownload($DownlHandle,$Array[$i][9])
EndFunc
Func Clicked_Cancel_Buttons($ControlID,$NotificationCode)
$WPARAM = OnEventExGetWParam($ControlID,$NotificationCode)
$LPARAM = OnEventExGetLParam($ControlID,$NotificationCode)
$HWND = OnEventExGetHWND($ControlID,$NotificationCode)
$DownlHandle = EnvGet($ControlID)
CancelDownload($DownlHandle)
EndFunc
Func ProgressLoop($Array)
Dim $TempArray[1][10]
$complete = 2
For $i = 0 To UBound($Array) - 1
$ProgressTime = $Array[$i][8]
Sleep($ProgressTime)
$InfoArray = DownloadGetInfo($Array[$i][7])
if Not @error Then
if ($InfoArray[0][0]) Then _
$TotalReadTimes = $InfoArray[1][0]
$NumberOfBytesRead = $InfoArray[2][0]
$FileSize = $InfoArray[3][0]
$IsComplete = $InfoArray[4][0]
GUICtrlSetData($Array[$i][3],(100 / $FileSize) * $NumberOfBytesRead)
GUICtrlSetData($Array[$i][4],"( " & StringLeft(int($NumberOfBytesRead / 1024) / 1024 ,12) _
& " OF " & StringLeft(int($FileSize /1024) / 1024 ,12) & " ) MB")
If Not ($IsComplete) Then
$complete = 1
$TempArray[UBound($TempArray) -1][0] = $Array[$i][0]
$TempArray[UBound($TempArray) -1][1] = $Array[$i][1]
$TempArray[UBound($TempArray) -1][2] = $Array[$i][2]
$TempArray[UBound($TempArray) -1][3] = $Array[$i][3]
$TempArray[UBound($TempArray) -1][4] = $Array[$i][4]
$TempArray[UBound($TempArray) -1][5] = $Array[$i][5]
$TempArray[UBound($TempArray) -1][6] = $Array[$i][6]
$TempArray[UBound($TempArray) -1][7] = $Array[$i][7]
$TempArray[UBound($TempArray) -1][8] = $Array[$i][8]
$TempArray[UBound($TempArray) -1][9] = $Array[$i][9]
ReDim $TempArray[UBound($TempArray) +1][10]
Else
GUICtrlSetBkColor($Array[$i][4] - 2, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor($Array[$i][4], $GUI_BKCOLOR_TRANSPARENT)
EndIf
EndIf
Next
if $complete = 2 Then
GUIDelete($Array[0][0])
Else
ReDim $TempArray[UBound($TempArray) - 1][10]
$Array = $TempArray
EndIf
Return $complete
EndFunc
Func DownloaderMultiFiles(ByRef $Array,$link,$FileName,$iFlag = 1,$ProgressTime = 500)
if Not IsArray($Array) Then
Dim $Array[1][10]
$Array[0][0] = GUICreate("Downloader Progress", 785, 140, 5, 200, _
BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW _
,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
Else
ReDim $Array[UBound($Array) + 1][10]
EndIf
If $iFlag = 1 Then
$OutDir = StringSplit($FileName,"\")
if Not FileExists(StringTrimRight($FileName,StringLen($OutDir[$OutDir[0]]))) _
Then DirCreate(StringTrimRight($FileName,StringLen($OutDir[$OutDir[0]])))
$Array[UBound($Array) - 1][1] = $link
$Array[UBound($Array) - 1][2] = $FileName
GUICtrlCreateLabel(StringLeft($OutDir[$OutDir[0]],23), 10, 10 + ((UBound($Array) - 1) * 30), 170, 20, BitOR($SS_CENTER,$WS_BORDER))
Else
$Array[UBound($Array) - 1][1] = $link
GUICtrlCreateLabel("< [ Memory ] >", 10, 10 + ((UBound($Array) - 1) * 30), 170, 20, BitOR($SS_CENTER,$WS_BORDER))
EndIf
GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Array[UBound($Array) - 1][3] = GUICtrlCreateProgress(190, 10 + ((UBound($Array) - 1) * 30), 200, 20)
$Array[UBound($Array) - 1][4] = GUICtrlCreateLabel("", 400, 10 + ((UBound($Array) - 1) * 30), 250, 20,BitOR($SS_CENTER,$WS_BORDER))
GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Array[UBound($Array) - 1][5] = GUICtrlCreateButton("Pause", 655, 10 + ((UBound($Array) - 1) * 30), 60,20)
GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
$Array[UBound($Array) - 1][6] = GUICtrlCreateButton("Cancel", 720, 10 + ((UBound($Array) - 1) * 30), 60,20)
GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
$Array[UBound($Array) - 1][7]  = DownloadFile($Array[UBound($Array) - 1][1],$Array[UBound($Array) - 1][2],100,$iFlag)
EnvSet($Array[UBound($Array) - 1][5],$Array[UBound($Array) - 1][7])
EnvSet($Array[UBound($Array) - 1][6],$Array[UBound($Array) - 1][7])
$Array[UBound($Array) - 1][8] = $ProgressTime
Return $Array[UBound($Array) - 1][5]
EndFunc
Func DownloadFile($Url,$FilePath,$BytesNumberAtaTime,$iFlag,$MemSize = 0)
Local $tag_xParams ="Ptr GetAddressFunc;DWORD DownlCount;Ptr DownlThreadH;" & _
"Ptr DownlOInte;Ptr hMemParams"
Local $tag_StParams = "Ptr DownlStrUrl;DWORD DownliTest;Ptr DownlFile;Ptr DownlOUrl;" & _
"DWORD DownlMovePos;ptr DownlBytePtr;Ptr DownlhMemory;DWORD DownlFileSize;" &  _
"DWORD DownlByteAtaTime;DWORD DownlBytesRead;DWORD DownlTotalReadTimes;" & _
"DWORD DownlComplete;DWORD DownlError;DWORD DownlPause;DWORD DownlMemSize;" & _
"DWORD DownlNewDownl"
if ($BytesNumberAtaTime <= 0 Or ($iFlag <> 1 And $iFlag <> 2)) Then return SetError(1)
Local $xParamsSize = DllStructGetSize(DllStructCreate($tag_xParams))
if (Not($hMemParams)) Then $hMemParams = _MemGlobalAlloc($xParamsSize ,$GHND)
Local $nxParams = DllStructCreate($tag_xParams,_MemGlobalLock($hMemParams))
if (Not(DllStructGetData($nxParams,"DownlOUrl"))) Then
Local $DownlOInte = Internet_Open("OPEN")
if(Not($DownlOInte)) Then return SetError(2)
DllStructSetData($nxParams,"DownlOInte",$DownlOInte)
EndIf
Local $DownlTest , $DownlFile
if ($iFlag = 1) Then
$DownlTest = 1
$DownlFile = _WinAPI_CreateFile($FilePath, 1)
if (@error) Then return SetError(3)
Else
$DownlTest = 0
EndIf
Local $nCount = DllStructGetData($nxParams,"DownlCount")
Local $SizeOfPtr = DllStructGetSize(DllStructCreate("ptr"))
Local $StParamsSize = DllStructGetSize(DllStructCreate($tag_StParams))
Local $NewhMemParams = _MemGlobalAlloc($StParamsSize,$GHND)
Local $vStParams = DllStructCreate($tag_StParams,_MemGlobalLock($NewhMemParams))
Local $NewMemPtrs = _MemGlobalAlloc((($nCount + 1) * $SizeOfPtr),$GHND)
Local $NewMemPtrslLock = _MemGlobalLock($NewMemPtrs)
Local $NewMemPtrsSt = DllStructCreate("ptr[" & ($nCount + 1) & "]",$NewMemPtrslLock)
Local $MemPtrsPtr = DllStructGetData($nxParams,"hMemParams")
if ($MemPtrsPtr) Then
Local $MemPrtsHandles = GlobalHandle($MemPtrsPtr)
Local $NewMemPtrsPtr = DllStructGetPtr($NewMemPtrsSt)
_MemMoveMemory($MemPtrsPtr,$NewMemPtrsPtr,_MemGlobalSize($MemPrtsHandles))
_MemGlobalFree($MemPrtsHandles)
EndIf
DllStructSetData($NewMemPtrsSt,1,$NewhMemParams,($nCount + 1))
DllStructSetData($nxParams,"hMemParams",_MemGlobalLock($NewMemPtrs))
Local $vhMemory = _MemGlobalAlloc(((StringLen($Url) + 2) * 2),$GHND)
Local $vhMemorySt = DllStructCreate("WCHAR[" & StringLen($Url) + 2 & "]",_MemGlobalLock($vhMemory))
DllStructSetData($vhMemorySt,1,$Url)
DllStructSetData($vStParams,"DownlStrUrl",$vhMemory)
DllStructSetData($vStParams,"DownliTest",$DownlTest)
DllStructSetData($vStParams,"DownlFile",$DownlFile)
DllStructSetData($vStParams,"DownlByteAtaTime",$BytesNumberAtaTime)
DllStructSetData($vStParams,"DownlMemSize",$MemSize)
DllStructSetData($vStParams,"DownlNewDownl",1)
DllStructSetData($nxParams,"DownlCount",($nCount + 1))
if (Not(DllStructGetData($nxParams,"DownlThreadH"))) Then
DllStructSetData($nxParams,"GetAddressFunc",DllCallbackGetPtr($GetAddressFuncReg))
$DownlThreadH = CreateThread(GetSaveFunc(),_MemGlobalLock($hMemParams))
if @error Then
_MemGlobalFree($hMemParams)
_MemGlobalFree($NewhMemParams)
_MemGlobalFree($vhMemory)
_WinAPI_CloseHandle($DownlFile)
$hMemParams = 0
$hMemFunc = 0
Return SetError(4)
EndIf
DllStructSetData($nxParams,"DownlThreadH",$DownlThreadH)
EndIf
Return DllStructGetData($nxParams,"DownlCount") ; Return $DownlNum // DownloadGetInfo($DownlNum)
EndFunc
Func GetAddressFunc($FuncNu)
Local $ProcAdds
Switch($FuncNu)
Case 1
$ProcAdds = DllCall($Kernel32O,"ptr","GetProcAddress","ptr",$Kernel32M,"str","LoadLibraryW")
if @error Then Return 0
$ProcAdds = $ProcAdds[0]
Case 2
$ProcAdds = DllCall($Kernel32O,"ptr","GetProcAddress","ptr",$Kernel32M,"str","GetProcAddress")
if @error Then Return 0
$ProcAdds = $ProcAdds[0]
EndSwitch
Return $ProcAdds
EndFunc
Func DownloadGetInfo($DownlNum)
Local $tag_StParams = "Ptr DownlStrUrl;DWORD DownliTest;Ptr DownlFile;Ptr DownlOUrl;" & _
"DWORD DownlMovePos;ptr DownlBytePtr;Ptr DownlhMemory;DWORD DownlFileSize;" &  _
"DWORD DownlByteAtaTime;DWORD DownlBytesRead;DWORD DownlTotalReadTimes;" & _
"DWORD DownlComplete;DWORD DownlError;DWORD DownlPause;DWORD DownlMemSize;" & _
"DWORD DownlNewDownl"
Local $tag_xParams ="Ptr GetAddressFunc;DWORD DownlCount;Ptr DownlThreadH;" & _
"Ptr DownlOInte;Ptr hMemParams"
Local $nxParams = DllStructCreate($tag_xParams,_MemGlobalLock($hMemParams))
$nCount = DllStructGetData($nxParams,"DownlCount")
if ($DownlNum < 1 Or $DownlNum > $nCount) Then Return SetError(1)
Local $MemPtrsPtr = DllStructGetData($nxParams,"hMemParams")
Local $NewMemPtrsSt = DllStructCreate("ptr[" & $nCount & "]",$MemPtrsPtr)
Local $WhMemParams = DllStructGetData($NewMemPtrsSt,1,$DownlNum)
Local $vStParams = DllStructCreate($tag_StParams,_MemGlobalLock($WhMemParams))
Local $DownloadInfo[6][2]
$DownloadInfo[0][1] = "hMemory"
$DownloadInfo[0][0] = DllStructGetData($vStParams,"DownlhMemory")
$DownloadInfo[1][1] = "TotalReadTimes"
$DownloadInfo[1][0] = DllStructGetData($vStParams,"DownlTotalReadTimes")
$DownloadInfo[2][1] = "NumberOfBytesRead"
$DownloadInfo[2][0] = DllStructGetData($vStParams,"DownlBytesRead")
$DownloadInfo[3][1] = "FileSize"
$DownloadInfo[3][0] = DllStructGetData($vStParams,"DownlFileSize")
$DownloadInfo[4][1] = "IsComplete"
$DownloadInfo[4][0] = DllStructGetData($vStParams,"DownlComplete")
$DownloadInfo[5][1] = "IsError"
$DownloadInfo[5][0] = DllStructGetData($vStParams,"DownlError")

Return $DownloadInfo
EndFunc
Func PauseDownload($DownlNum,$BOOL_Pause)
Local $tag_StParams = "Ptr DownlStrUrl;DWORD DownliTest;Ptr DownlFile;Ptr DownlOUrl;" & _
"DWORD DownlMovePos;ptr DownlBytePtr;Ptr DownlhMemory;DWORD DownlFileSize;" &  _
"DWORD DownlByteAtaTime;DWORD DownlBytesRead;DWORD DownlTotalReadTimes;" & _
"DWORD DownlComplete;DWORD DownlError;DWORD DownlPause;DWORD DownlMemSize;" & _
"DWORD DownlNewDownl"
Local $tag_xParams ="Ptr GetAddressFunc;DWORD DownlCount;Ptr DownlThreadH;" & _
"Ptr DownlOInte;Ptr hMemParams"
Local $nxParams = DllStructCreate($tag_xParams,_MemGlobalLock($hMemParams))
$nCount = DllStructGetData($nxParams,"DownlCount")
if ($DownlNum < 1 Or $DownlNum > $nCount) Then Return SetError(1,0,False)
Local $MemPtrsPtr = DllStructGetData($nxParams,"hMemParams")
Local $NewMemPtrsSt = DllStructCreate("ptr[" & $nCount & "]",$MemPtrsPtr)
Local $WhMemParams = DllStructGetData($NewMemPtrsSt,1,$DownlNum)
Local $vStParams = DllStructCreate($tag_StParams,_MemGlobalLock($WhMemParams))
if ($BOOL_Pause) Then
DllStructSetData($vStParams,"DownlPause",1)
Else
DllStructSetData($vStParams,"DownlPause",0)
EndIf
Return True
EndFunc
Func CancelDownload($DownlNum)
Local $tag_StParams = "Ptr DownlStrUrl;DWORD DownliTest;Ptr DownlFile;Ptr DownlOUrl;" & _
"DWORD DownlMovePos;ptr DownlBytePtr;Ptr DownlhMemory;DWORD DownlFileSize;" &  _
"DWORD DownlByteAtaTime;DWORD DownlBytesRead;DWORD DownlTotalReadTimes;" & _
"DWORD DownlComplete;DWORD DownlError;DWORD DownlPause;DWORD DownlMemSize;" & _
"DWORD DownlNewDownl"
Local $tag_xParams ="Ptr GetAddressFunc;DWORD DownlCount;Ptr DownlThreadH;" & _
"Ptr DownlOInte;Ptr hMemParams"
if Not(PauseDownload($DownlNum,True)) Then Return SetError(1,@error,False)
Local $nxParams = DllStructCreate($tag_xParams,_MemGlobalLock($hMemParams))
$nCount = DllStructGetData($nxParams,"DownlCount")
Local $MemPtrsPtr = DllStructGetData($nxParams,"hMemParams")
Local $NewMemPtrsSt = DllStructCreate("ptr[" & $nCount & "]",$MemPtrsPtr)
Local $WhMemParams = DllStructGetData($NewMemPtrsSt,1,$DownlNum)
Local $vStParams = DllStructCreate($tag_StParams,_MemGlobalLock($WhMemParams))
_WinAPI_CloseHandle(DllStructGetData($vStParams,"DownlFile"))
Internet_CloseHandle(DllStructGetData($vStParams,"DownlOUrl"))
_MemGlobalFree(DllStructGetData($vStParams,"DownlhMemory"))
DllStructSetData($vStParams,"DownlComplete",2)
Return True
EndFunc
Func SaveFuncFileToByteFunc($SaveFuncFile = "SaveFuncFile.bin",$OutFile = "ByteFuncFile.au3")
Local $FileSize = FileGetSize($SaveFuncFile) , $nBytes
if @error Then Return SetError(1,0,False)
Local $tBuffer = DllStructCreate("byte[" & $FileSize & "]")
Local $hFile = _WinAPI_CreateFile($SaveFuncFile, 2, 2)
if @error Then Return SetError(2,0,False)
_WinAPI_ReadFile($hFile,DllStructGetPtr($tBuffer),$FileSize,$nBytes)
if @error Then Return SetError(3,0,False)
_WinAPI_CloseHandle($hFile)
Local $StrByte = DllStructGetData($tBuffer,1)
Local $Fuc = 'Func GetSaveFunc()' & @CRLF
$Fuc &= 'Local $StrByte = ""' & @CRLF
For $i = 1 To StringLen($StrByte) Step 80
$Fuc &= '$StrByte &= "' & StringMid($StrByte,$i,80) & '"' & @CRLF
Next
$Fuc &= 'if Not($hMemFunc) Then $hMemFunc = _MemGlobalAlloc(BinaryLen($StrByte),$GHND)' & @CRLF
$Fuc &= '$ByteStruct = DllStructCreate("byte[" & BinaryLen($StrByte) & "]",_MemGlobalLock($hMemFunc))' & @CRLF
$Fuc &= 'DllStructSetData($ByteStruct,1,$StrByte)' & @CRLF
$Fuc &= 'Return _MemGlobalLock($hMemFunc)' & @CRLF
$Fuc &= 'EndFunc' & @CRLF
Local $OpFile = FileOpen($OutFile,2)
if @error Then Return SetError(4,0,False)
FileWrite($OpFile,$Fuc)
if @error Then Return SetError(5,0,False)
FileClose($OpFile)
Return True
EndFunc
Func Internet_Open($lpszAgent)
$HINTERNET = DllCall("Wininet.dll","ptr","InternetOpenW","wstr", _
$lpszAgent,"DWORD",0,"wstr","","wstr","","DWORD",0)
if @error Or $HINTERNET[0] = 0 Then Return SetError(1)
Return $HINTERNET[0]
EndFunc
Func Internet_CloseHandle($hInternet)
$BOOL = DllCall("Wininet.dll","BOOL","InternetCloseHandle","ptr",$hInternet)
if @error Or $BOOL[0] = 0 Then Return SetError(1)
Return $BOOL[0]
EndFunc
Func CreateThread($lpStartAddress,$lpParameter)
Local $HANDLE = DllCall($Kernel32O,"ptr","CreateThread","ptr",0,"int",0,"ptr", _
$lpStartAddress,"ptr",$lpParameter,"DWORD",0,"DWORD*",0)
if @error Or $HANDLE[0] = 0 Then Return SetError(1)
Return $HANDLE[0]
EndFunc
Func GlobalHandle($pMem)
Local $HGLOBAL = DllCall($Kernel32O,"ptr","GlobalHandle","ptr",$pMem)
if @error Or $HGLOBAL[0] = 0 Then Return SetError(1)
Return $HGLOBAL[0]
EndFunc
Func GetSaveFunc()
Local $StrByte = ""
$StrByte &= "0x558BEC81C404F0FFFF5081C4ECFEFFFF53565766C7855CFFFFFF570066C7855EFFFFFF690066C7"
$StrByte &= "8560FFFFFF6E0066C78562FFFFFF690066C78564FFFFFF6E0066C78566FFFFFF650066C78568FFFF"
$StrByte &= "FF740066C7856AFFFFFF2E0066C7856CFFFFFF640066C7856EFFFFFF6C0066C78570FFFFFF6C0066"
$StrByte &= "C78572FFFFFF0000C68548FFFFFF49C68549FFFFFF6EC6854AFFFFFF74C6854BFFFFFF65C6854CFF"
$StrByte &= "FFFF72C6854DFFFFFF6EC6854EFFFFFF65C6854FFFFFFF74C68550FFFFFF4FC68551FFFFFF70C685"
$StrByte &= "52FFFFFF65C68553FFFFFF6EC68554FFFFFF55C68555FFFFFF72C68556FFFFFF6CC68557FFFFFF57"
$StrByte &= "C68558FFFFFF00C68538FFFFFF48C68539FFFFFF74C6853AFFFFFF74C6853BFFFFFF70C6853CFFFF"
$StrByte &= "FF51C6853DFFFFFF75C6853EFFFFFF65C6853FFFFFFF72C68540FFFFFF79C68541FFFFFF49C68542"
$StrByte &= "FFFFFF6EC68543FFFFFF66C68544FFFFFF6FC68545FFFFFF57C68546FFFFFF0066C7851CFFFFFF4B"
$StrByte &= "0066C7851EFFFFFF650066C78520FFFFFF720066C78522FFFFFF6E0066C78524FFFFFF650066C785"
$StrByte &= "26FFFFFF6C0066C78528FFFFFF330066C7852AFFFFFF320066C7852CFFFFFF2E0066C7852EFFFFFF"
$StrByte &= "640066C78530FFFFFF6C0066C78532FFFFFF6C0066C78534FFFFFF0000C6850CFFFFFF47C6850DFF"
$StrByte &= "FFFF65C6850EFFFFFF74C6850FFFFFFF4CC68510FFFFFF61C68511FFFFFF73C68512FFFFFF74C685"
$StrByte &= "13FFFFFF45C68514FFFFFF72C68515FFFFFF72C68516FFFFFF6FC68517FFFFFF72C68518FFFFFF00"
$StrByte &= "C68500FFFFFF43C68501FFFFFF6CC68502FFFFFF6FC68503FFFFFF73C68504FFFFFF65C68505FFFF"
$StrByte &= "FF48C68506FFFFFF61C68507FFFFFF6EC68508FFFFFF64C68509FFFFFF6CC6850AFFFFFF65C6850B"
$StrByte &= "FFFFFF00C685ECFEFFFF49C685EDFEFFFF6EC685EEFEFFFF74C685EFFEFFFF65C685F0FEFFFF72C6"
$StrByte &= "85F1FEFFFF6EC685F2FEFFFF65C685F3FEFFFF74C685F4FEFFFF43C685F5FEFFFF6CC685F6FEFFFF"
$StrByte &= "6FC685F7FEFFFF73C685F8FEFFFF65C685F9FEFFFF48C685FAFEFFFF61C685FBFEFFFF6EC685FCFE"
$StrByte &= "FFFF64C685FDFEFFFF6CC685FEFEFFFF65C685FFFEFFFF0066C785D4FEFFFF6D0066C785D6FEFFFF"
$StrByte &= "730066C785D8FEFFFF760066C785DAFEFFFF630066C785DCFEFFFF720066C785DEFEFFFF740066C7"
$StrByte &= "85E0FEFFFF2E0066C785E2FEFFFF640066C785E4FEFFFF6C0066C785E6FEFFFF6C0066C785E8FEFF"
$StrByte &= "FF0000C645F85FC645F977C645FA74C645FB6FC645FC69C645FD00C685C8FEFFFF47C685C9FEFFFF"
$StrByte &= "6CC685CAFEFFFF6FC685CBFEFFFF62C685CCFEFFFF61C685CDFEFFFF6CC685CEFEFFFF41C685CFFE"
$StrByte &= "FFFF6CC685D0FEFFFF6CC685D1FEFFFF6FC685D2FEFFFF63C685D3FEFFFF00C685BCFEFFFF47C685"
$StrByte &= "BDFEFFFF6CC685BEFEFFFF6FC685BFFEFFFF62C685C0FEFFFF61C685C1FEFFFF6CC685C2FEFFFF4C"
$StrByte &= "C685C3FEFFFF6FC685C4FEFFFF63C685C5FEFFFF6BC685C6FEFFFF00C685ACFEFFFF47C685ADFEFF"
$StrByte &= "FF6CC685AEFEFFFF6FC685AFFEFFFF62C685B0FEFFFF61C685B1FEFFFF6CC685B2FEFFFF55C685B3"
$StrByte &= "FEFFFF6EC685B4FEFFFF6CC685B5FEFFFF6FC685B6FEFFFF63C685B7FEFFFF6BC685B8FEFFFF00C6"
$StrByte &= "85A0FEFFFF47C685A1FEFFFF6CC685A2FEFFFF6FC685A3FEFFFF62C685A4FEFFFF61C685A5FEFFFF"
$StrByte &= "6CC685A6FEFFFF46C685A7FEFFFF72C685A8FEFFFF65C685A9FEFFFF65C685AAFEFFFF00C6858CFE"
$StrByte &= "FFFF49C6858DFEFFFF6EC6858EFEFFFF74C6858FFEFFFF65C68590FEFFFF72C68591FEFFFF6EC685"
$StrByte &= "92FEFFFF65C68593FEFFFF74C68594FEFFFF52C68595FEFFFF65C68596FEFFFF61C68597FEFFFF64"
$StrByte &= "C68598FEFFFF46C68599FEFFFF69C6859AFEFFFF6CC6859BFEFFFF65C6859CFEFFFF00C645EC57C6"
$StrByte &= "45ED72C645EE69C645EF74C645F065C645F146C645F269C645F36CC645F465C645F5008B45088945"
$StrByte &= "E88B55E88B0A894DE46A01FF55E48945E06A02FF55E48BD88D855CFFFFFF50FF55E08945DC8D9548"
$StrByte &= "FFFFFF52FF75DCFFD38945D88D8D38FFFFFF51FF75DCFFD38945D48D851CFFFFFF50FF55E08945D0"
$StrByte &= "8D950CFFFFFF52FF75D0FFD38945CC8D8D00FFFFFF51FF75D0FFD38945C88D85ECFEFFFF50FF75DC"
$StrByte &= "FFD38945C48D95D4FEFFFF52FF55E08945C08D4DF851FF75C0FFD38945BC8D85C8FEFFFF50FF75D0"
$StrByte &= "FFD38945B88D95BCFEFFFF52FF75D0FFD38945B48D8DACFEFFFF51FF75D0FFD38945B08D85A0FEFF"
$StrByte &= "FF50FF75D0FFD38945AC8D958CFEFFFF52FF75DCFFD38945A88D4DEC51FF75D0FFD38945A433C089"
$StrByte &= "4584E97A0200008B55E88B4A108B4584FF3481FF55B48BD8837B2C000F855C020000837B34000F85"
$StrByte &= "520200008B730C8B430889458C8B7B1C8B43048945948B53208955908B4B38894D988B43108B5314"
$StrByte &= "837B3C000F84C0000000C74580D0070000FF33FF55B46A006A006A006A00508B4DE8FF710CFF55D8"
$StrByte &= "8BF0FF55CC89459C6A008D4580508D95ECEEFFFF526A0556FF55D48BF8837D9C007506FF55CC8945"
$StrByte &= "9C85F6740485FF7526FF758CFF55C856FF55C4FF33FF55AC8B459C894330C7432C0100000033D289"
$StrByte &= "533CE9AF010000FF33FF55AC8D8DECEEFFFF51FF55BC598BF8837D94007523837D980074038B7D98"
$StrByte &= "576A42FF55B8894588FF7588FF55B48BD08B458889431889531489730C897B1C33C9894B3CE96401"
$StrByte &= "0000837D94000F84D60000003BF8751CFF758CFF55C856FF55C48B459C894330C7432C01000000E9"
$StrByte &= "3A010000837B34000F85300100008BD72BD03B559076058B4D90EB048BCF2BC8894DA0FF75A06A42"
$StrByte &= "FF55B889857CFFFFFFFFB57CFFFFFFFF55B4898578FFFFFF8D45A050FF75A0FFB578FFFFFF56FF55"
$StrByte &= "A88BF8FF55CC89459C85FF7406837DA0007725FFB57CFFFFFFFF55ACFF758CFF55C856FF55C48B45"
$StrByte &= "9C894330C7432C01000000E9B60000006A008D55A052FF75A0FFB578FFFFFFFF758CFF55A48B4DA0"
$StrByte &= "014B108B45A0014324FF4328FFB57CFFFFFFFF55ACE9840000003BF8751356FF55C48B559C895330"
$StrByte &= "C7432C01000000EB6D837B340075672BF889BD74FFFFFF8B4D903B8D74FFFFFF73058D4D90EB068D"
$StrByte &= "8D74FFFFFF8B09894DA003D08BC28D55A052FF75A05056FF55A88BF8FF55CC89459C85FF7406837D"
$StrByte &= "A000771356FF55C48B459C894330C7432C01000000EB0F8B55A00153108B4DA0014B24FF4328FF45"
$StrByte &= "848B45E88B50043B55840F8777FDFFFFE968FDFFFF33C05F5E5B8BE55DC2040090"
if Not($hMemFunc) Then $hMemFunc = _MemGlobalAlloc(BinaryLen($StrByte),$GHND)
$ByteStruct = DllStructCreate("byte[" & BinaryLen($StrByte) & "]",_MemGlobalLock($hMemFunc))
DllStructSetData($ByteStruct,1,$StrByte)
Return _MemGlobalLock($hMemFunc)
EndFunc
 

 

GUICtrlSetOnEventEx.au3

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $NotifyStruct = 0 , $TagNotifyStruct = ""
; GUICtrlSetOnEventEx($Control_ID_HWnd,$NotificationCode,$Function)
;$NotificationCode ==> (WM_COMMAND Notification Code And WM_NOTIFY Notification Code)
;$Function ==> ($ControlID,$NotificationCode) ; Return :Note use
Func GUICtrlSetOnEventEx($Control_ID_HWnd,$NotificationCode,$Function)
$handle = DLLCallbackRegister($Function,"none","int;int")
if $handle = 0 Then Return False
DllCallbackFree($handle)
if IsHWnd($Control_ID_HWnd) Then
$hWnd = $Control_ID_HWnd
$ControlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd)
If @error Then Return False
$ControlID = $ControlID[0]
if Not ($ControlID) Then Return False
Else
$ControlID = $Control_ID_HWnd
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
EndIf
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
if Not IsDllStruct($NotifyStruct) Then
Local $count = 1
$Len = StringLen($Function)
$TagNotifyStruct = _
"int count;WPARAM WPARAM;LPARAM LPARAM;int Test;int " & String($hWnd & $iNotificationCode) & _
";HWND HWND" & String($count) & ";int ControlID" & String($count) & ";int NotificationCode" & _
String($count) & ";char Function" & String($count) & "[" & String($Len) & "]"
$NotifyStruct = DllStructCreate($TagNotifyStruct)
DllStructSetData($NotifyStruct,"count",$count)
DllStructSetData($NotifyStruct,String($hWnd & $iNotificationCode),$count)
DllStructSetData($NotifyStruct,"HWND" & String($count),$hWnd)
DllStructSetData($NotifyStruct,"ControlID" & String($count),$ControlID)
DllStructSetData($NotifyStruct,"NotificationCode" & String($count),$NotificationCode)
DllStructSetData($NotifyStruct,"Function" & String($count),$Function)
Else
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if ($count) Then Return False
Local $count = DllStructGetData($NotifyStruct,"count") + 1
$Len = StringLen($Function)
$TagNotifyStruct &= _
";int " & String($hWnd & $iNotificationCode) & ";HWND HWND" & String($count) & _
";int NotificationCode" & String($count) & ";int ControlID" & String($count) & _
";char Function" & String($count) & "[" & String($Len) & "]"
$iLength = DllStructGetSize($NotifyStruct)
$iNotifyStruct = DllStructCreate($TagNotifyStruct)
DllCall("kernel32.dll","none","RtlMoveMemory","ptr",DllStructGetPtr($iNotifyStruct) _
,"ptr",DllStructGetPtr($NotifyStruct),"ulong_ptr",$iLength)
$NotifyStruct = $iNotifyStruct
DllStructSetData($NotifyStruct,"count",$count)
DllStructSetData($NotifyStruct,String($hWnd & $iNotificationCode),$count)
DllStructSetData($NotifyStruct,"HWND" & String($count),$hWnd)
DllStructSetData($NotifyStruct,"ControlID" & String($count),$ControlID)
DllStructSetData($NotifyStruct,"NotificationCode" & String($count),$NotificationCode)
DllStructSetData($NotifyStruct,"Function" & String($count),$Function)
EndIf
GUIRegisterMsg($WM_NOTIFY,"OnEventExProc")
GUIRegisterMsg($WM_COMMAND,"OnEventExProc")
Return True
EndFunc

Func OnEventExProc($hWnd,$Msg,$wParam,$lParam)
Select
Case $Msg = $WM_NOTIFY
Local $OnEventExtagNMHDR = "hwnd hWndFrom;uint_ptr IDFrom;INT Code"
$tNMHDR = DllStructCreate($OnEventExtagNMHDR, $lParam)
$MsgHwnd = DllStructGetData($tNMHDR, "hWndFrom")
$MsgCode = DllStructGetData($tNMHDR, "Code")
Case $Msg = $WM_COMMAND
$MsgHwnd = $lParam
$MsgCode = BitShift($wParam, 16)
EndSelect
$iMsgCode = $MsgCode
if StringInStr($MsgCode,"-") Then _
$iMsgCode = StringReplace($MsgCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($MsgHwnd & $iMsgCode))
if Not ($count) Then Return $GUI_RUNDEFMSG
DllStructSetData($NotifyStruct,"WPARAM",$wParam)
DllStructSetData($NotifyStruct,"LPARAM",$lParam)
$OnEvHWND = DllStructGetData($NotifyStruct,"HWND" & String($count))
$ControlID = DllStructGetData($NotifyStruct,"ControlID" & String($count))
$OnEvNotificationCode = DllStructGetData($NotifyStruct,"NotificationCode" & String($count))
$OnEvFunction = DllStructGetData($NotifyStruct,"Function" & String($count))
DllStructSetData($NotifyStruct,"Test",1)
if ($MsgHwnd = $OnEvHWND And $MsgCode = $OnEvNotificationCode) Then _
Call($OnEvFunction,$ControlID,$OnEvNotificationCode)
DllStructSetData($NotifyStruct,"Test",0)
Return $GUI_RUNDEFMSG
EndFunc

Func OnEventExGetWParam($ControlID,$NotificationCode)
$Test = DllStructGetData($NotifyStruct,"Test")
if Not ($Test) Then Return False
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if Not ($count) Then Return False
Return DllStructGetData($NotifyStruct,"WPARAM")
EndFunc

Func OnEventExGetLParam($ControlID,$NotificationCode)
$Test = DllStructGetData($NotifyStruct,"Test")
if Not ($Test) Then Return False
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if Not ($count) Then Return False
Return DllStructGetData($NotifyStruct,"LPARAM")
EndFunc

Func OnEventExGetHWND($ControlID,$NotificationCode)
$Test = DllStructGetData($NotifyStruct,"Test")
if Not ($Test) Then Return False
$hWnd = GUICtrlGetHandle($ControlID)
if Not IsHWnd($hWnd) Then Return False
$iNotificationCode = $NotificationCode
if StringInStr($NotificationCode,"-") Then _
$iNotificationCode = StringReplace($NotificationCode,"-","A")
$count = DllStructGetData($NotifyStruct,String($hWnd & $iNotificationCode))
if Not ($count) Then Return False
Return DllStructGetData($NotifyStruct,"HWND" & String($count))
EndFunc

;C++ Compiler 5.5
;download
https://downloads.embarcadero.com/free/c_builder
;C++Builder Compiler (bcc compiler) free download. See the file bcb5tool.hlp in the Help
;directory for complete instructions on using the C++Builder Compiler and Command Line Tools.
;Windows English 8.5MB
;C:BorlandBCC55Binbcc32.exe
Compiler.au3

#include <WinAPI.au3>
#include <Clipboard.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>


;C++ Compiler 5.5
;download
;https://downloads.embarcadero.com/free/c_builder
;C++Builder Compiler (bcc compiler) free download. See the file bcb5tool.hlp in the Help
;directory for complete instructions on using the C++Builder Compiler and Command Line Tools.
;Windows English 8.5MB
;C:\Borland\BCC55\Bin\bcc32.exe

$var1 = FileOpenDialog("Choose bcc32.exe","C:\Borland\BCC55\Bin", "(*.Exe)", 1 + 4 ,"bcc32.exe")
if @error Then Exit
$var2 = FileOpenDialog("Choose ThreadDownload.cpp",@ScriptDir, "(*.cpp)", 1 + 4 ,"ThreadDownload.cpp")
if @error Then Exit
$var3 = FileSelectFolder("Choose Out File folder.", @ScriptDir)
if @error Then Exit
Dim $iPatch1 = "" , $iPatch2 = $var2 , $iPatch3 = $var3 , $foo , $line = ""
$Patch1 = StringSplit($var1,"\")
For $i = 1 To $Patch1[0] - 2
$iPatch1 &= $Patch1[$i] & "\"
Next
$iPatch1 = StringTrimRight($iPatch1,1)
FileChangeDir(FileGetShortName($iPatch1 & "\Bin\"))
$Command = "bcc32.exe " & _
"-I" & FileGetShortName($iPatch1 & "\Include ") & _
"-L" & FileGetShortName($iPatch1 & "\Lib ") & _
"-e" & FileGetShortName($iPatch3) & "\ThreadDownload.exe " & _
"-tW " & FileGetShortName($iPatch2)
$foo = Run($Command,"", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
ClipPut( $line)
MsgBox(0, "STDOUT", $line)
Wend

$MenText = _
'<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">' & @CRLF & _
'<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">' & @CRLF & _
' <security>' & @CRLF & _
'    <requestedPrivileges>' & @CRLF & _
'    <requestedExecutionLevel level="asInvoker" uiAccess="false">'& @CRLF & _
'    </requestedExecutionLevel>' & @CRLF & _
'    </requestedPrivileges>' & @CRLF & _
' </security>' & @CRLF & _
' </trustInfo>' & @CRLF & _
' <dependency>' & @CRLF & _
' <dependentAssembly>' & @CRLF & _
'    <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"></assemblyIdentity>' & @CRLF & _
' </dependentAssembly>' & @CRLF & _
' </dependency>' & @CRLF & _
'</assembly>'


$DataStruct = StringToDataStruct($MenText)
UpdateResource($iPatch3 & "\ThreadDownload.exe",24,1,$DataStruct)

Func StringToDataStruct($Text)
;$Flag=1 Return BYTE DataStruct
;$Flag=2 Return Char DataStruct
$Len = StringLen($Text)
if $Len = 0 Then $Len = 1
$DataStruct = DllStructCreate("byte[" & $Len & "]")
DllStructSetData($DataStruct,1,$Text)
Return $DataStruct
EndFunc

Func UpdateResource($OutFile,$lpType,$lpName,ByRef $DataStruct)
Local $lpData = DllStructGetPtr($DataStruct),$cbData = DllStructGetSize($DataStruct),$wLanguage = 0
$HANDLE = DllCall("kernel32.dll","HANDLE","BeginUpdateResourceW","wstr",$OutFile,"BOOL",False)
if @error Or $HANDLE[0] = 0 Then Return SetError(1,0,False)
$hUpdate = $HANDLE[0]
if IsString($lpType) Then
$DataType1 = "wstr"
$lpType = StringUpper($lpType)
ELSE
$DataType1 = "long"
$lpType = Int($lpType)
EndIf
if IsString($lpName) Then
$DataType2 = "wstr"
$lpName = StringUpper($lpName)
ELSE
$DataType2 = "long"
$lpName = Int($lpName)
EndIf
$BOOL = DllCall("kernel32.dll","BOOL","UpdateResourceW","HANDLE",$hUpdate,$DataType1 _
,$lpType,$DataType2,$lpName,"WORD",$wLanguage,"ptr",$lpData,"DWORD",$cbData)
if @error Or $BOOL[0] = 0 Then Return SetError(2,0,False)
$BOOL = DllCall("kernel32.dll","BOOL","EndUpdateResourceW","HANDLE",$hUpdate,"BOOL",False)
if @error Or $BOOL[0] = 0 Then Return SetError(3,0,False)
Return True
EndFunc

Thred Library
Started by wolf9228 , Feb 05 2011 10:57 PM
'?do=embed' frameborder='0' data-embedContent>>
ThreadDownload.cpp

#include <windows.h>
#include <stdio.h>
#include "ThreadDownload.h"

int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,INT)
{

DownloadFile(L"http://www.swfmax.com/get/SWF.max.exe",L"D:\\SWF.max.exe",100,1,0);
DownloadFile(L"http://download.winzip.com/winzip150.exe",L"D:\\winzip150.exe",100,1,0);

MSG msg;
while (GetMessage(&msg,0,0,0))
{
if (!TranslateAccelerator(msg.hwnd,0, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
     return 0;
}

ThreadDownload.h

#include <windows.h>
#include <stdio.h>

typedef struct _xParams{
void* GetAddressFunc;
DWORD DownlCount;
void* DownlThreadH;
void* DownlOInte;
void** hMemParams;
}xParams,*PxParams;

typedef struct _StParams {
void* DownlStrUrl;
DWORD DownliTest;
void* DownlFile;
void* DownlOUrl;
DWORD DownlMovePos;
BYTE* DownlBytePtr;
void* DownlhMemory;
DWORD DownlFileSize;
DWORD DownlByteAtaTime;
DWORD DownlBytesRead;
DWORD DownlTotalReadTimes;
DWORD DownlComplete;
DWORD DownlError;
DWORD DownlPause;
DWORD DownlMemSize;
DWORD DownlNewDownl;
}StParams,*PStParams;
void* hMemParams;

typedef struct {
HGLOBAL hMemory;
DWORD TotalReadTimes;
DWORD NumberOfBytesRead;
DWORD FileSize;
DWORD IsComplete;
DWORD IsError;} NetInfoR;

HMODULE ShlwapiLibrary = LoadLibraryW(L"Shlwapi.dll");
HMODULE ShellLibrary = LoadLibraryW(L"Shell32.dll");
HMODULE Kernel32Library = LoadLibraryW(L"Kernel32.dll");
HMODULE WininetLibrary = LoadLibrary("Wininet.dll");
typedef BOOL (WINAPI* Params1) (HWND,WCHAR*,SECURITY_ATTRIBUTES*);
Params1 vSHCreateDirectoryExW = (Params1) GetProcAddress(ShellLibrary,"SHCreateDirectoryExW");
typedef BOOL (WINAPI* Params2) (WCHAR*);
Params2 vPathFileExistsW = (Params2) GetProcAddress(ShlwapiLibrary,"PathFileExistsW");
BOOL File_ReadW(WCHAR* FilePath,BYTE** OutByteData,DWORD* OutSizeOfByteData);
DWORD File_WriteW(WCHAR* FileName,LPVOID Data,DWORD SizeOfData,BOOL CreateDirectory = false);
DWORD GetFuncSize(LPVOID Func,LPVOID NextFunc);
void* WINAPI GetAddressFunc(int FuncNu);
DWORD WINAPI SaveFunc(void* Params);
void WINAPI NextFunc();
typedef DWORD (WINAPI* iSaveFunc)(void*);
WCHAR* PtrToByteCode(void* Pointer,int SizeOfPointer,WCHAR* VariableName);
WCHAR* StringPtrToStringCodeA(char* nString,WCHAR* VariableName);
WCHAR* StringPtrToStringCodeW(WCHAR* nString,WCHAR* VariableName);
WCHAR* StringMidW(WCHAR* iString,int Start,int Count);
WCHAR* StringLeftW(WCHAR* iString,int Count);
WCHAR* StringRightW(WCHAR* iString,int Count);
WCHAR* StringUpperW(WCHAR* iString);
WCHAR* StringAddW(WCHAR* StrA,WCHAR* StrB);
WCHAR* CRLF();
DWORD WINAPI DownloadFile(LPCWSTR Url,LPCWSTR FilePath,DWORD BytesNumberAtaTime,DWORD iFlag,DWORD MemSize);
HANDLE Internet_Open(LPCWSTR lpszAgent,DWORD dwAccessType,LPCWSTR lpszProxyName,LPCWSTR lpszProxyBypass,DWORD dwFlags);
BOOL DownloadGetInfo(DWORD DownlNum,NetInfoR &NInfo);
BOOL PauseDownload(DWORD DownlNum,BOOL Pause);
BOOL CancelDownload(DWORD DownlNum);
BOOL Internet_CloseHandle(HANDLE hInternet);

DWORD WINAPI SaveFunc(void* Params)
{
#define _min(a, b) (((a) < (b)) ? (a) : (b))
typedef struct _mParams{
void* GetAddressFunc;
DWORD DownlCount;
void* DownlThreadH;
void* DownlOInte;
void** hMemParams;
}mParams,*PmParams;
typedef struct _nStParams {
void* DownlStrUrl;
DWORD DownliTest;
void* DownlFile;
void* DownlOUrl;
DWORD DownlMovePos;
BYTE* DownlBytePtr;
void* DownlhMemory;
DWORD DownlFileSize;
DWORD DownlByteAtaTime;
DWORD DownlBytesRead;
DWORD DownlTotalReadTimes;
DWORD DownlComplete;
DWORD DownlError;
DWORD DownlPause;
DWORD DownlMemSize;
DWORD DownlNewDownl;
}nStParams,*PnStParams;
typedef void* (WINAPI* Params1)(int);
typedef void* (WINAPI* Params2)(void*);
typedef void* (WINAPI* Params3)(void*,void*);
typedef void* (WINAPI* Params4)(void*,void*,void*,DWORD,DWORD,void*);
typedef BOOL (WINAPI* Params5)(void*,DWORD,void*,void*,void*);
typedef DWORD (WINAPI* Params6)();
typedef BOOL (WINAPI* Params7)(void*);
typedef BOOL (WINAPI* Params8)(void*);
typedef int (__cdecl* Params9)(void*);
typedef void* (WINAPI* Params10)(int,int);
typedef void* (WINAPI* Params11)(void*);
typedef BOOL (WINAPI* Params12)(void*);
typedef void* (WINAPI* Params13)(void*);
typedef BOOL (WINAPI* Params14) (void*,void*,DWORD,void*);
typedef BOOL (WINAPI* Params15) (void*,void*,DWORD,void*,void*);
WCHAR String1[12];
String1[0] = L'W';
String1[1] = L'i';
String1[2] = L'n';
String1[3] = L'i';
String1[4] = L'n';
String1[5] = L'e';
String1[6] = L't';
String1[7] = L'.';
String1[8] = L'd';
String1[9] = L'l';
String1[10] = L'l';
String1[11] = NULL;
char String2[17];
String2[0] = 73;
String2[1] = 110;
String2[2] = 116;
String2[3] = 101;
String2[4] = 114;
String2[5] = 110;
String2[6] = 101;
String2[7] = 116;
String2[8] = 79;
String2[9] = 112;
String2[10] = 101;
String2[11] = 110;
String2[12] = 85;
String2[13] = 114;
String2[14] = 108;
String2[15] = 87;
String2[16] = 0;
char String3[15];
String3[0] = 72;
String3[1] = 116;
String3[2] = 116;
String3[3] = 112;
String3[4] = 81;
String3[5] = 117;
String3[6] = 101;
String3[7] = 114;
String3[8] = 121;
String3[9] = 73;
String3[10] = 110;
String3[11] = 102;
String3[12] = 111;
String3[13] = 87;
String3[14] = 0;
WCHAR String4[13];
String4[0] = L'K';
String4[1] = L'e';
String4[2] = L'r';
String4[3] = L'n';
String4[4] = L'e';
String4[5] = L'l';
String4[6] = L'3';
String4[7] = L'2';
String4[8] = L'.';
String4[9] = L'd';
String4[10] = L'l';
String4[11] = L'l';
String4[12] = NULL;
char String5[13];
String5[0] = 71;
String5[1] = 101;
String5[2] = 116;
String5[3] = 76;
String5[4] = 97;
String5[5] = 115;
String5[6] = 116;
String5[7] = 69;
String5[8] = 114;
String5[9] = 114;
String5[10] = 111;
String5[11] = 114;
String5[12] = 0;
char String6[12];
String6[0] = 67;
String6[1] = 108;
String6[2] = 111;
String6[3] = 115;
String6[4] = 101;
String6[5] = 72;
String6[6] = 97;
String6[7] = 110;
String6[8] = 100;
String6[9] = 108;
String6[10] = 101;
String6[11] = 0;
char String7[20];
String7[0] = 73;
String7[1] = 110;
String7[2] = 116;
String7[3] = 101;
String7[4] = 114;
String7[5] = 110;
String7[6] = 101;
String7[7] = 116;
String7[8] = 67;
String7[9] = 108;
String7[10] = 111;
String7[11] = 115;
String7[12] = 101;
String7[13] = 72;
String7[14] = 97;
String7[15] = 110;
String7[16] = 100;
String7[17] = 108;
String7[18] = 101;
String7[19] = 0;
WCHAR String8[11];
String8[0] = L'm';
String8[1] = L's';
String8[2] = L'v';
String8[3] = L'c';
String8[4] = L'r';
String8[5] = L't';
String8[6] = L'.';
String8[7] = L'd';
String8[8] = L'l';
String8[9] = L'l';
String8[10] = NULL;
char String9[6];
String9[0] = 95;
String9[1] = 119;
String9[2] = 116;
String9[3] = 111;
String9[4] = 105;
String9[5] = 0;
char String10[12];
String10[0] = 71;
String10[1] = 108;
String10[2] = 111;
String10[3] = 98;
String10[4] = 97;
String10[5] = 108;
String10[6] = 65;
String10[7] = 108;
String10[8] = 108;
String10[9] = 111;
String10[10] = 99;
String10[11] = 0;
char String11[11];
String11[0] = 71;
String11[1] = 108;
String11[2] = 111;
String11[3] = 98;
String11[4] = 97;
String11[5] = 108;
String11[6] = 76;
String11[7] = 111;
String11[8] = 99;
String11[9] = 107;
String11[10] = 0;
char String12[13];
String12[0] = 71;
String12[1] = 108;
String12[2] = 111;
String12[3] = 98;
String12[4] = 97;
String12[5] = 108;
String12[6] = 85;
String12[7] = 110;
String12[8] = 108;
String12[9] = 111;
String12[10] = 99;
String12[11] = 107;
String12[12] = 0;
char String13[11];
String13[0] = 71;
String13[1] = 108;
String13[2] = 111;
String13[3] = 98;
String13[4] = 97;
String13[5] = 108;
String13[6] = 70;
String13[7] = 114;
String13[8] = 101;
String13[9] = 101;
String13[10] = 0;
char String14[17];
String14[0] = 73;
String14[1] = 110;
String14[2] = 116;
String14[3] = 101;
String14[4] = 114;
String14[5] = 110;
String14[6] = 101;
String14[7] = 116;
String14[8] = 82;
String14[9] = 101;
String14[10] = 97;
String14[11] = 100;
String14[12] = 70;
String14[13] = 105;
String14[14] = 108;
String14[15] = 101;
String14[16] = 0;
char String15[10];
String15[0] = 87;
String15[1] = 114;
String15[2] = 105;
String15[3] = 116;
String15[4] = 101;
String15[5] = 70;
String15[6] = 105;
String15[7] = 108;
String15[8] = 101;
String15[9] = 0;

PmParams vmParams = (PmParams)Params;
Params1 vGetAddressFunc = (Params1)vmParams->GetAddressFunc;
Params2 vLoadLibraryW = (Params2)vGetAddressFunc(1);
Params3 vGetProcAddress = (Params3)vGetAddressFunc(2);
void* Wininet = vLoadLibraryW(String1);
Params4 vInternetOpenUrlW = (Params4)vGetProcAddress(Wininet,String2);
Params5 vHttpQueryInfoW = (Params5)vGetProcAddress(Wininet,String3);
void* Kernel32 = vLoadLibraryW(String4);
Params6 vGetLastError = (Params6)vGetProcAddress(Kernel32,String5);
Params7 vCloseHandle = (Params7)vGetProcAddress(Kernel32,String6);
Params8 vInternetCloseHandle = (Params8)vGetProcAddress(Wininet,String7);
void* Msvcrt = vLoadLibraryW(String8);
Params9 v_wtoi = (Params9)vGetProcAddress(Msvcrt,String9);
Params10 vGlobalAlloc = (Params10)vGetProcAddress(Kernel32,String10);
Params11 vGlobalLock = (Params11)vGetProcAddress(Kernel32,String11);
Params12 vGlobalUnlock = (Params12)vGetProcAddress(Kernel32,String12);
Params13 vGlobalFree = (Params13)vGetProcAddress(Kernel32,String13);
Params14 vInternetReadFile = (Params14)vGetProcAddress(Wininet,String14);
Params15 vWriteFile = (Params15)vGetProcAddress(Kernel32,String15);

DWORD BytesRead,MovePos = 0,Err,MemSize;
DWORD FileSize, DownlTest , ByteAtaTime;
void* DownlOUrl,*DownlFile,*Url;
BOOL RT;
HGLOBAL hMemory;
BYTE* BytePtr;

while(1)
{

for (int i = 0; i < vmParams->DownlCount; i++)
{

PnStParams vParams = (PnStParams)vGlobalLock(vmParams->hMemParams[i]);
if (vParams->DownlComplete || vParams->DownlPause) continue;

DownlOUrl = vParams->DownlOUrl;
DownlFile = vParams->DownlFile;
FileSize = vParams->DownlFileSize;
DownlTest = vParams->DownliTest;
ByteAtaTime = vParams->DownlByteAtaTime;
MemSize = vParams->DownlMemSize;
MovePos = vParams->DownlMovePos;
BytePtr = vParams->DownlBytePtr;

if (vParams->DownlNewDownl)
{
DWORD BufferLength = 2000;
WCHAR BufferFileSize[2000];
Url = vGlobalLock(vParams->DownlStrUrl);
DownlOUrl = vInternetOpenUrlW(vmParams->DownlOInte,Url,NULL,NULL,NULL,NULL);
Err = vGetLastError();
RT = vHttpQueryInfoW(DownlOUrl,5,BufferFileSize,&BufferLength,NULL);
if (!Err) Err = vGetLastError();
if(!DownlOUrl || !RT)
{
vCloseHandle(DownlFile);
vInternetCloseHandle(DownlOUrl);
vGlobalFree(vParams->DownlStrUrl);
vParams->DownlError = Err;
vParams->DownlComplete = 1;
vParams->DownlNewDownl = 0;
continue;
}

vGlobalFree(vParams->DownlStrUrl);
FileSize = v_wtoi(BufferFileSize);
if (!DownlTest)
{
if (MemSize) FileSize = MemSize;
hMemory = vGlobalAlloc(GHND,FileSize);
BytePtr = (BYTE*)vGlobalLock(hMemory);
vParams->DownlhMemory = hMemory;
vParams->DownlBytePtr = BytePtr;
}
vParams->DownlOUrl = DownlOUrl;
vParams->DownlFileSize = FileSize;
vParams->DownlNewDownl = 0;
continue;
}

if (DownlTest)
{
if (MovePos == FileSize)
{
vCloseHandle(DownlFile);
vInternetCloseHandle(DownlOUrl);
vParams->DownlError = Err;
vParams->DownlComplete = 1;
continue;
}
if (vParams->DownlPause) continue;
BytesRead = _min(ByteAtaTime,FileSize - MovePos);
void* nhMemory = vGlobalAlloc(GHND,BytesRead);
BYTE* nBytePtr = (BYTE*)vGlobalLock(nhMemory);
RT = vInternetReadFile(DownlOUrl,nBytePtr,BytesRead,&BytesRead);
Err = vGetLastError();
if(!RT || BytesRead <= 0)
{
vGlobalFree(nhMemory);
vCloseHandle(DownlFile);
vInternetCloseHandle(DownlOUrl);
vParams->DownlError = Err;
vParams->DownlComplete = 1;
continue;
}
vWriteFile(DownlFile,nBytePtr,BytesRead,&BytesRead,NULL);
vParams->DownlMovePos += BytesRead;
vParams->DownlBytesRead += BytesRead;
vParams->DownlTotalReadTimes++;
vGlobalFree(nhMemory);
} else {
if (MovePos == FileSize)
{
vInternetCloseHandle(DownlOUrl);
vParams->DownlError = Err;
vParams->DownlComplete = 1;
continue;
}
if (vParams->DownlPause) continue;
BytesRead = min(ByteAtaTime,FileSize - MovePos);
BYTE* OutPtr = BytePtr + MovePos;
RT = vInternetReadFile(DownlOUrl,OutPtr,BytesRead,&BytesRead);
Err = vGetLastError();
if(!RT || BytesRead <= 0)
{
vInternetCloseHandle(DownlOUrl);
vParams->DownlError = Err;
vParams->DownlComplete = 1;
continue;
}
vParams->DownlMovePos += BytesRead;
vParams->DownlBytesRead += BytesRead;
vParams->DownlTotalReadTimes++;
}}}

return 0;
}
void WINAPI NextFunc(){}

DWORD WINAPI DownloadFile(LPCWSTR Url,LPCWSTR FilePath,DWORD BytesNumberAtaTime,DWORD iFlag,DWORD MemSize)
{

DWORD DBOOL = (iFlag != 1 && iFlag != 2);
if (BytesNumberAtaTime <= 0 || DBOOL) return 0;

if (!(hMemParams)) hMemParams = GlobalAlloc(GHND,sizeof(xParams));
PxParams nxParams = (PxParams)GlobalLock(hMemParams);
if (!nxParams->DownlOInte)
{
nxParams->DownlOInte = Internet_Open((LPCWSTR) "OPEN",NULL,NULL,NULL,0);
if(!nxParams->DownlOInte) return 0;
}

DWORD DownlTest;
HANDLE DownlFile;
if (iFlag == 1)
{
DownlTest = 1;
DownlFile = CreateFileW(FilePath,GENERIC_WRITE,
0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if (DownlFile == INVALID_HANDLE_VALUE) return 0;
} else {
DownlTest = 0;
}

DWORD nCount = nxParams->DownlCount;
void* nhMemParams = GlobalAlloc(GHND,sizeof(StParams));
PStParams vStParams = (PStParams)GlobalLock(nhMemParams);
void** NewhMemParams = new void*[(nCount + 1)];
MoveMemory(NewhMemParams,nxParams->hMemParams,nCount * sizeof(void*));
NewhMemParams[nCount] = nhMemParams;
nxParams->hMemParams = NewhMemParams;
HGLOBAL vhMemory = GlobalAlloc(GHND,((wcslen(Url) + 1) * 2));
MoveMemory(GlobalLock(vhMemory),(BYTE*)Url,(wcslen(Url) * 2));
vStParams->DownlStrUrl = vhMemory;
vStParams->DownliTest = DownlTest;
vStParams->DownlFile = DownlFile;
vStParams->DownlByteAtaTime = BytesNumberAtaTime;
vStParams->DownlMemSize = MemSize;
vStParams->DownlNewDownl = 1;
nxParams->DownlCount++;

DWORD ThreadID;
if (!nxParams->DownlThreadH)
{
DWORD FuncSize = GetFuncSize(&SaveFunc,&NextFunc);
File_WriteW(L"SaveFuncFile.bin",&SaveFunc,FuncSize);
BYTE* OutByteData = new BYTE[FuncSize];
DWORD OutSizeOfByteData;
File_ReadW(L"SaveFuncFile.bin",&OutByteData,&OutSizeOfByteData);
iSaveFunc nSaveFunc = (iSaveFunc)OutByteData;
nxParams->GetAddressFunc = (void*)GetAddressFunc;
nxParams->DownlThreadH = CreateThread(NULL,0,SaveFunc,GlobalLock(hMemParams),0,&ThreadID);
}

return nxParams->DownlCount;

}

void* WINAPI GetAddressFunc(int FuncNu)
{
void* ProcAdds;
switch(FuncNu)
{
case 1:
{
ProcAdds = (void*)GetProcAddress(Kernel32Library,"LoadLibraryW");
}
break;
case 2:
{
ProcAdds = (void*)GetProcAddress(Kernel32Library,"GetProcAddress");
}
break;
}
return ProcAdds;
}


BOOL DownloadGetInfo(DWORD DownlNum,NetInfoR &NInfo)
{
PxParams nxParams = (PxParams)GlobalLock(hMemParams);
DWORD nCount = nxParams->DownlCount;
if (DownlNum < 1 || DownlNum > nCount) return false;
DownlNum--;
void* WhMemParams = nxParams->hMemParams[DownlNum];
PStParams vStParams = (PStParams)GlobalLock(WhMemParams);
NInfo.TotalReadTimes = vStParams->DownlTotalReadTimes;
NInfo.NumberOfBytesRead = vStParams->DownlBytesRead;
NInfo.FileSize = vStParams->DownlFileSize;
NInfo.IsComplete = vStParams->DownlComplete;
NInfo.IsError = vStParams->DownlError;
if ((!vStParams->DownliTest) && (vStParams->DownlComplete == 1))
NInfo.hMemory = vStParams->DownlhMemory;
return true;

}

BOOL PauseDownload(DWORD DownlNum,BOOL Pause)
{

PxParams nxParams = (PxParams)GlobalLock(hMemParams);
DWORD nCount = nxParams->DownlCount;
if (DownlNum < 1 || DownlNum > nCount) return false;
DownlNum--;
void* WhMemParams = nxParams->hMemParams[DownlNum];
PStParams vStParams = (PStParams)GlobalLock(WhMemParams);
if (Pause != 0)
{
vStParams->DownlPause = 1;
} else {
vStParams->DownlPause = 0;
}

return true;
}

BOOL CancelDownload(DWORD DownlNum)
{
PxParams nxParams = (PxParams)GlobalLock(hMemParams);
DWORD nCount = nxParams->DownlCount;
if (DownlNum < 1 || DownlNum > nCount) return false;
PauseDownload(DownlNum,true);
DownlNum--;
void* WhMemParams = nxParams->hMemParams[DownlNum];
PStParams vStParams = (PStParams)GlobalLock(WhMemParams);
CloseHandle(vStParams->DownlFile);
Internet_CloseHandle(vStParams->DownlOUrl);
GlobalFree(vStParams->DownlhMemory);
vStParams->DownlComplete = 2;
return true;
}

DWORD GetFuncSize(LPVOID Func,LPVOID NextFunc)
{
return (DWORD)((size_t)NextFunc - (size_t)Func);
}

WCHAR* PtrToByteCode(void* Pointer,int SizeOfPointer,WCHAR* VariableName)
{
if (Pointer == NULL || VariableName == NULL || SizeOfPointer == NULL) return NULL;
BYTE* nPointer = (BYTE*)Pointer;
WCHAR* vString = L"BYTE ";
vString = StringAddW(vString,VariableName);
vString = StringAddW(vString,L"[");
WCHAR* StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",SizeOfPointer);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L"];");
vString = StringAddW(vString,CRLF());
for (int RowNu = 0 ; RowNu < SizeOfPointer; RowNu++)
{
vString = StringAddW(vString,VariableName);
vString = StringAddW(vString,L"[");
StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",RowNu);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L"] = ");
StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",nPointer[RowNu]);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L";");
vString = StringAddW(vString,CRLF());
}
return vString;
}

WCHAR* StringPtrToStringCodeA(char* nString,WCHAR* VariableName)
{
if (nString == NULL || VariableName == NULL) return NULL;
int SizeOfPointer = strlen(nString) + 1;
BYTE* nPointer = (BYTE*)nString;
WCHAR* vString = L"char ";
vString = StringAddW(vString,VariableName);
vString = StringAddW(vString,L"[");
WCHAR* StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",SizeOfPointer);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L"];");
vString = StringAddW(vString,CRLF());
for (int RowNu = 0 ; RowNu < SizeOfPointer; RowNu++)
{
vString = StringAddW(vString,VariableName);
vString = StringAddW(vString,L"[");
StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",RowNu);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L"] = ");
StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",nPointer[RowNu]);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L";");
vString = StringAddW(vString,CRLF());
}
return vString;
}

WCHAR* StringPtrToStringCodeW(WCHAR* nString,WCHAR* VariableName)
{
if (nString == NULL || VariableName == NULL) return NULL;
int nLen = wcslen(nString) + 1;
WCHAR* vString = L"WCHAR ";
vString = StringAddW(vString,VariableName);
vString = StringAddW(vString,L"[");
WCHAR* StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",nLen);
vString = StringAddW(vString,StringNu);
vString = StringAddW(vString,L"];");
vString = StringAddW(vString,CRLF());
for (int RowNu = 0 ; RowNu < nLen; RowNu++)
{
vString = StringAddW(vString,VariableName);
vString = StringAddW(vString,L"[");
StringNu = new WCHAR[100];
swprintf(StringNu,L"%d",RowNu);
vString = StringAddW(vString,StringNu);
WCHAR* vCharStr = StringMidW(nString,RowNu + 1,1);
if (RowNu < (nLen - 1) && wcscmp(vCharStr,L"") != 0)
{
vString = StringAddW(vString,L"] = L'");
vString = StringAddW(vString,vCharStr);
vString = StringAddW(vString,L"';");
} else {
vString = StringAddW(vString,L"] = ");
vString = StringAddW(vString,L"NULL");
vString = StringAddW(vString,L";");
}
vString = StringAddW(vString,CRLF());
}
return vString;
}


BOOL File_ReadW(WCHAR* FilePath,BYTE** OutByteData,DWORD* OutSizeOfByteData)
{

DWORD FileSize , HiDWORD , BytesRead;

if (!(vPathFileExistsW(FilePath))) return false;
HANDLE hFile = CreateFileW(FilePath, GENERIC_READ, FILE_SHARE_READ, NULL,OPEN_EXISTING,0,NULL);
if (hFile == NULL)
{
return false;
}

FileSize = GetFileSize(hFile,&HiDWORD);
BYTE* ByteData = new BYTE[FileSize];
BOOL pReturn = ReadFile(hFile,ByteData,FileSize,&BytesRead,0);
if (!(pReturn))
{
return false;
}
CloseHandle(hFile);

*(OutByteData) = ByteData;
*(OutSizeOfByteData) = FileSize;

return true;

}


DWORD File_WriteW(WCHAR* FileName,LPVOID Data,DWORD SizeOfData,BOOL CreateDirectory)
{

DWORD IBytesWrite = 0;
int vLastError = -1 , DirectoryLen = 0;
WCHAR* RtStr = NULL, *Directory = NULL;

if (FileName == NULL)
{
SetLastError(1);
return NULL;
}

if (CreateDirectory)
{
RtStr = wcsrchr(FileName,L'\\');
if (RtStr)
{
DirectoryLen = (wcslen(FileName) - wcslen(RtStr));
if (DirectoryLen > 2) // > 2 More than The length Of C: D: E: ....
{
Directory = new WCHAR[(DirectoryLen + 1)];
RtlMoveMemory(Directory,FileName,(DirectoryLen * sizeof(WCHAR)));
Directory[DirectoryLen] = L'\0';
vSHCreateDirectoryExW(NULL,Directory,NULL);
vLastError = GetLastError();
if (vLastError != 0 && vLastError != ERROR_ALREADY_EXISTS && vLastError != ERROR_FILE_EXISTS)
{
SetLastError(2);
return NULL;
}}}}

HANDLE CrFile = CreateFileW(FileName,GENERIC_EXECUTE | GENERIC_READ | GENERIC_WRITE,
NULL,NULL,CREATE_ALWAYS,NULL,NULL);
if (CrFile == NULL)
{
SetLastError(3);
return NULL;
}

BOOL Result = WriteFile(CrFile,Data,SizeOfData,&IBytesWrite,0);
if (!(Result))
{
CloseHandle(CrFile);
SetLastError(4);
return NULL;
}
CloseHandle(CrFile);

SetLastError(0);
return IBytesWrite;

}

HANDLE Internet_Open(LPCWSTR lpszAgent,DWORD dwAccessType,LPCWSTR lpszProxyName,LPCWSTR lpszProxyBypass,DWORD dwFlags)
{

typedef HANDLE (CALLBACK* parameters) (LPCWSTR,DWORD,LPCWSTR,LPCWSTR,DWORD);
parameters Proc = (parameters) GetProcAddress(WininetLibrary,"InternetOpenW");
return Proc(lpszAgent,dwAccessType,lpszProxyName,lpszProxyBypass,dwFlags);

}

BOOL Internet_CloseHandle(HANDLE hInternet)
{

typedef BOOL (WINAPI* parameters)(HANDLE);
parameters Proc = (parameters) GetProcAddress(WininetLibrary,"InternetCloseHandle");
return Proc(hInternet);

}

WCHAR* StringMidW(WCHAR* iString,int Start,int Count)
{
if (iString == NULL) return NULL;
int len = wcslen(iString) , iCount = Count;
if (Count < 1 || Start > len) return NULL;
if (Start < 1) Start = 1;
if (Count > (len - Start)) iCount == (len - Start);
return StringRightW(StringLeftW(iString,(Start + iCount) - 1),iCount);
}

WCHAR* StringLeftW(WCHAR* iString,int Count)
{
if (iString == NULL || Count < 1 ) return NULL;
if (Count > wcslen(iString)) Count = wcslen(iString);
WCHAR* StrA = new wchar_t[Count + 1];
wcsncpy(StrA,iString,Count);
StrA[Count]='\0';
return StrA;
}

WCHAR* StringRightW(WCHAR* iString,int Count)
{
if (iString == NULL || Count < 1 ) return NULL;
if (Count > wcslen(iString)) Count = wcslen(iString);
WCHAR* StrA = new wchar_t[Count + 1];
wcsncpy(StrA,iString + (wcslen(iString) - Count),Count);
StrA[Count]='\0';
return StrA;
}

WCHAR* StrToUpperW(WCHAR* iString)
{
if (iString == NULL) return iString;
int vLen = wcslen(iString);
WCHAR* pString = new WCHAR[vLen + 1];
for (int i = 0 ; i < vLen; i++)
{pString[i] = towupper(iString[i]);}
pString[vLen] = L'\0';
return pString;
}

WCHAR* StringAddW(WCHAR* StrA,WCHAR* StrB)
{
if (StrA == NULL) return StrB;
if (StrB == NULL) return StrA;
int nLen = wcslen(StrA), vLen = wcslen(StrB);
WCHAR* StrC = new WCHAR[nLen + vLen + 1];
wcscpy(StrC,StrA);
wcscpy(StrC + nLen,StrB);
StrC[nLen + vLen] = L'\0';
return StrC;
}

WCHAR* CRLF()
{
return StringAddW(L"\r",L"\n");
}
Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I stopped reading after chapter 6...I think the butler did it.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try to use [autoit][/autoit] tags where possible and did you use (code)(/code) tags for the above?

Edit: Stripped out square brackets in the code tags.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I'm unsure exactly what this is/is for.

I'm unsure exactly what this is/is for.

This programming :P


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

I stopped reading after chapter 6...I think the butler did it.

Programmer can understand script with little explanation and sometimes

Without any explanation


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

wolf9228,

But we would prefer you to add a few words of explanation when you post your very complex scripts - please be kind enough to do so in future. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Programmer can understand script with little explanation and sometimes

Without any explanation

I don't like to say this but it is an AutoIt Forum, therefore not everyone has knowledge of C++, therefore it would help in this instance if you were to post a more detailed description for those who only program in AutoIt.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Try to use [autoit][/autoit] tags where possible and did you use (code)(/code) tags for the above?

Edit: Stripped out square brackets in the code tags.

When using the [Autoit] code to contain the script sometimes

some errors occur So I preferred to use the

code

Thank you

Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

------------------------

Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

wolf9228,

But we would prefer you to add a few words of explanation when you post your very complex scripts - please be kind enough to do so in future. :)

M23

Difficult or even impossible to explain complex script such as

This script is possible to only put forward the idea of the script

Thank you :)


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

wolf9228,

Difficult or even impossible to explain complex script

Then what is the point of posting it? :huh:

Besides, that was not a request - if you post another long script without any explanation, just wait and see what happens to it. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

It's a multithreaded way to download files, where the second thread is written in C.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0