MT4调用Windows API进行文件读写操作
/*导入相关函数*/
#import "kernel32.dll"
int CreateDirectoryW(string directoryName,int type);
int CreateFileW(string Filename, int AccessMode, int ShareMode, int PassAsZero, int CreationMode, int FlagsAndAttributes, int AlsoPassAsZero);
int WriteFile(int FileHandle, string BufferPtr, int BufferLength, int &BytesWritten[], int PassAsZero);
int ReadFile(int FileHandle, uchar &Buffer[], int BufferLength, int & BytesRead[], int PassAsZero);
int CloseHandle(int FileHandle);
int GetFileSize(int FileHandle, int PassAsZero);
#import
/*读文件*/
string ReadFile(string Filename)
{
string strFileContents = "";
int h = CreateFileW(Filename, 0x80000000 /*GENERIC_READ*/, /*SHARE READ|WRITE*/, , /*OPEN_EXISTING*/, , );
if (h == -) {
// Open failed
} else {
int sz = GetFileSize(h, );
if (sz > ) {
uchar buffer[];
ArrayResize(buffer, sz);
int read[];
ReadFile(h, buffer, sz, read, );
if (read[] == sz)
strFileContents = CharArrayToString(buffer, , read[]);
}
}
CloseHandle(h);
return strFileContents;
}
/*写文件*/
void WriteFile(string filePath,string str)
{
int BytesWritten[] = {};
uchar WriteBuffer[];
StringToCharArray(str, WriteBuffer);
int FileHandle = CreateFileW(FileName, , , , , , );
WriteFile(FileHandle,WriteBuffer,StringLen(str),BytesWritten,);
CloseHandle(FileHandle);
}
MT4调用Windows API进行文件读写操作的更多相关文章
- C#调用windows API的一些方法
使用C#调用windows API(从其它地方总结来的,以备查询) C#调用windows API也可以叫做C#如何直接调用非托管代码,通常有2种方法: 1. 直接调用从 DLL 导出的函数. 2. ...
- C#调用Windows API函数截图
界面如下: 下面放了一个PictureBox 首先是声明函数: //这里是调用 Windows API函数来进行截图 //首先导入库文件 [System.Runtime.InteropServices ...
- PHP文件读写操作之文件写入代码
在PHP网站开发中,存储数据通常有两种方式,一种以文本文件方式存储,比如txt文件,一种是以数据库方式存储,比如Mysql,相对于数据库存储,文件存储并没有什么优势,但是文件读写操作在基本的PHP开发 ...
- 【转】用C#调用Windows API向指定窗口发送
一.调用Windows API. C#下调用Windows API方法如下: 1.引入命名空间:using System.Runtime.InteropServices; 2.引用需要使用的方法,格式 ...
- C#中调用Windows API的要点 .
介绍 API(Application Programming Interface),我想大家不会陌生,它是我们Windows编程的常客,虽然基于.Net平台的C#有了强大的类库,但是,我们还是不能否认 ...
- Kotlin入门(27)文件读写操作
Java的文件处理用到了io库java.io,该库虽然功能强大,但是与文件内容的交互还得通过输入输出流中转,致使文件读写操作颇为繁琐.因此,开发者通常得自己重新封装一个文件存取的工具类,以便在日常开发 ...
- 用C#调用Windows API向指定窗口发送按键消息 z
用C#调用Windows API向指定窗口发送 一.调用Windows API. C#下调用Windows API方法如下: 1.引入命名空间:using System.Runtime.Interop ...
- 用C#调用Windows API向指定窗口发送按键消息
一.调用Windows API. C#下调用Windows API方法如下: 1.引入命名空间:using System.Runtime.InteropServices; 2.引用需要使用的方法,格式 ...
- Kotlin入门-文件读写操作
转 https://blog.csdn.net/aqi00/article/details/83241762 Java的文件处理用到了io库java.io,该库虽然功能强大,但是与文件内容的交互还得通 ...
随机推荐
- MySQLWorkBench怎么设置主键自增长
参考 https://blog.csdn.net/qq_40472613/article/details/87858099 勾选AI选项,相当于执行了这个语句: AUTO_INCREMENT表示自增 ...
- jQuery,遍历表格每个单元格数据。
<table class="table table-hover table-bordered"> <thead> <tr> <th > ...
- CAD创建组(网页版)
主要用到函数说明: _DMxDrawX::CreateGroup 创建组.如果组名已经存在,就把实体加入组中.详细说明如下: 参数 说明 BSTR pszName 组名.,如果为空,创建匿名组 IDi ...
- CAD梦想看图6.0安卓版 20181022更新
下载地址: http://www.mxdraw.com/ndetail_10109.html 1. 保存上次的文件浏览位置和绘制颜色 2. 调整工具条按钮位置和文字 3. 增加测量距离和面积时的捕捉功 ...
- python vars模块
{'__file__': 'C:/Users/zhou/PycharmProjects/fullstack2/6_20/test.py', '__doc__': None, '__cached__': ...
- react 返回上一页
import * as React from 'react' import { Layout } from 'antd'; import creatHistory from 'history/crea ...
- NAT、NAPT(PAT)的基本概念和工作原理及区别
转自:http://blog.sina.com.cn/s/blog_5d302bd20100gprv.html 近年来,随着 Internet 的迅猛发展,连入 Internet 的主机数量成倍增长. ...
- input file 美化的方法
css input[type=file] 样式美化,input上传按钮美化 2014年8月29日 113210次浏览 由于明天公司组织出去游玩,今天把这两天的博客都写了吧,今天的内容是input[ty ...
- HDU - 6266 - HDU 6266 Hakase and Nano (博弈论)
题意: 有两个人从N个石子堆中拿石子,其中一个人可以拿两次,第二个人只能拿一次.最后拿完的人胜利. 思路: 类型 Hakase先 Hakase后 1 W L 1 1 W W 1 1 1 (3n) L ...
- Win10中创建Hyper-V虚拟机
Win10虚拟机创建方法方法 1 开始菜单->所有应用->Windows系统->控制面板,程序->启用或关闭Windows功能,勾选Hyper-V下所有选项 如果Hyper-V ...