CoolBreeze Posted December 20, 2010 Share Posted December 20, 2010 Hi, guys! [sorry for bad ENG.] #Include <EditConstants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global $sFile, $hFile, $iSize, $sData, $tData, $iRead $sFile = @SCRIPTDir & '\TEST.rar' $iSize = FileGetSize($sFile) $tData = DllStructCreate('byte[' & $iSize & ']') $hFile = _WinAPI_CreateFile($sFile, 2, 2, 2) _WinAPI_ReadFile($hFile, DllStructGetPtr($tData), $iSize, $iRead) _WinAPI_CloseHandle($hFile) $sData = '' For $i = 1 To $iSize $sData &= Hex(DllStructGetData($tData, 1, $i), 2) If Mod($i, 16) = 0 Then $sData &= @CRLF Else $sData &= ' ' EndIf Next $sData = StringTrimRight($sData, 2) FileWrite("hextext.txt", $sData) I wonna write large text file in "hex" from file whose size is <100Mb I`am tried...without success -> low memory BUT. "HHD_Hex_Editor" opening that large rar file in 5.sec and exporting for a short time, similar "hextext.txt" Some help? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 20, 2010 Moderators Share Posted December 20, 2010 BoRisk, I hope this does what you want: ; Open the file and read as bytes $hFile = FileOpen("test.rar", 16) $sByteContent = FileRead($hFile) FileClose($hFile) ; Convert the bytes to hex and remove the leading 0x $sHexContent = Stringtrimleft(StringToBinary($sByteContent), 2) ; Write the file $hFile = FileOpen("hextext.txt", 2) FileWrite($hFile, $sHexContent) FileClose($hFile) Please come back if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
CoolBreeze Posted December 21, 2010 Author Share Posted December 21, 2010 I am here again :P/First, Thank you for the attempt to help/I have appended two screenshot...First is the Error, i talked about that in the first postThe same is happening with my script. But its work with file smaller than ~~100KbSecond scrs. shows what I thought. Your hex_content compared with my._WinAPI, <-- There lies the secret.I would like to solve this. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 21, 2010 Moderators Share Posted December 21, 2010 BoRisk,First problem: I have no idea why your code produces that error on your machine. Does mine? Second problem: My fault, sorry. I removed the leading 0x and converted the binary - I only needed to do one or the other. Try this code:; Open the file and read as bytes $hFile = FileOpen("test.rar", 16) $sByteContent = FileRead($hFile) FileClose($hFile) ; Remove leading 0x $sHexContent = StringTrimLeft($sByteContent, 2) ; Write the file $hFile = FileOpen("hextext.txt", 2) FileWrite($hFile, $sHexContent) FileClose($hFile)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
CoolBreeze Posted December 21, 2010 Author Share Posted December 21, 2010 Again the same problem. Error allocating memory, your code-my code similarly I have idea. I'm going to try on another pc, Please test my script with file of 100Mb, If work, please tell me how much time he should, and what your machine configuration.. Tomorrow I will tell if it works on another machine. Link to comment Share on other sites More sharing options...
trancexx Posted December 21, 2010 Share Posted December 21, 2010 @Melba23, Hex() is to be used for that. As for memory problem, that's perfectly normal. BoRisk you are storing 100MB into a variable. Don't do that. That goes directly into RAM. Your HHD_Hex_Editor is using simple trick. It reads just enough bytes you can see at time, and when you scroll that control it moves file pointer forward or back and reads at that position. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
CoolBreeze Posted December 22, 2010 Author Share Posted December 22, 2010 You right. Thats the trick. OK, I changed the plan. I will try to view file in hex as that editor. I have no idea how to open in part, and show in GUI EDIT BOX, the highest possible rows In any case thank! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now