Last year, for some reason, I need to output a file's binary form to a text file in the format of the text. Similar to this: 4D 5A 90 00 03 00 00 04 00 00 ff ff 00b8 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 D0 00 00 000E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 6869 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 206D 6F 64 65 2E 0D 0D 0A 24 00 00 00 00 00 00 ... I think it is very simple: open the file, read the file, use a loop, use WSPrintf for each byte, then connect to LSTRCAT, write files, and get it. So I easily got the following code: // Note 1: You can understand several undefined variables as global variables. // Note 2: New is a macro that I defined, which looks according to the C Operator New.
// #define new (type *) (malloc (numberof (number))) Void save (void) {dWord dwsize, dwreaded, i; tchar szbyte [5]; // read source hFileSrc = CreateFile (szFileSrc, GENERIC_READ, 0, NULL, OPEN_ALWAYS, 0, NULL); dwSize = GetFileSize (hFileSrc, NULL); lpbySrc = NEW (BYTE, dwSize); ReadFile (hFileSrc, (LPVOID) lpbySrc, dwSize, & dwreaded, null); // The following mysize is a macro indicating the size of the buffer. Since the calculation size is more cumbersome and has nothing to do with this article, it is slightly lpdst = new (tchar, mysize); * LPDST = '/ 0' ; For (i = 0; i So in my code, every time you complete, LSTRCAT will not be annoying to find a finger, and then make a replication - this has caused a lot of unusual work, which is the cause of the Progress Bar getting more slower. After knowing the hardenal injury, I decided to manually implement the connection of the string at the end of the target string, borrow a variable to point to the target string. So I wrote the following code: void save (void) {DWORD DWSIZE, DWREAD, I, J, K; Tchar Szbyte [5]; // Read source file HFilesRC = CreateFile (szfilesrc, generic_read, 0, null, open_always , 0, NULL); DWSIZE = GetFileSize (HfileSRC, NULL); LPBYSRC = New (Byte, DWSize); ReadFile (HFilesRC, (LPVOID) LPBYSRC, DWSIZE, & DWREAD, NULL); // The following mysize is an indicator buffer The size of the size is more cumbersome due to the calculation size and has nothing to do with this article, so this is slightly lpdst = new (tchar, mysize); * lpdst = '/ 0'; j = 0; for (i = 0; i