长文本按行均分

易语言 2020-12-13 14:03:53

长文本按行均分

hFile = CreateFileA (文件名, #GENERIC_READ, 0, 0, #OPEN_EXISTING, 0, 0) ' 打开文件
GetFileSizeEx (hFile, size) ' 取文件尺寸
.如果真 (size = 0)
返回 (0)
.如果真结束
.如果真 (是否为空 (保存目录) = 假 且 保存目录 ≠ “”)
.如果真 (取文本右边 (保存目录, 1) ≠ “\”)
保存目录 = 保存目录 + “\”
.如果真结束
创建目录 (保存目录)
.如果真结束
text_ptr = HeapAlloc (GetProcessHeap (), #HEAP_ZERO_MEMORY, size + 8 + 1)
写到内存 (1, text_ptr, )
写到内存 (到整数 (size + 1), text_ptr + 4, )
写到内存 (text_ptr, 取变量地址 (text), )
text_ptr = text_ptr + 8
ReadFile (hFile, text_ptr, size, 0, 0) ' 读入文件