读取文件字节 - ReadBytesFromFile
函数简介
从文件中读取指定偏移量和大小的字节数据。
接口名称
ReadBytesFromFile
DLL调用
long ReadBytesFromFile(long instance, string filePath, int offset, long size);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| filePath | 字符串 | 要读取的文件完整路径。 |
| offset | 整数型 | 起始偏移量(字节)。 |
| size | 长整数型 | 读取的字节数,0 表示读取整个文件。 |
示例
C++
long instance = CreateCOLAPlugInterFace();
// 从文件开头读取1024字节
long bufPtr = ReadBytesFromFile(instance, "C:\\test\\data.bin", 0, 1024);
// 读取整个文件
long allPtr = ReadBytesFromFile(instance, "C:\\test\\data.bin", 0, 0);
FreeMemoryPtr(instance, bufPtr);
FreeMemoryPtr(instance, allPtr);
Python
# 待补充
返回值
返回字节缓冲区指针,失败返回0。
注意事项
- 返回的缓冲区指针需调用 [FreeMemoryPtr](/olaplug/其他/释放字节流内存 - FreeMemoryPtr.html) 接口释放内存。
