- 积分
- 41
- 最后登录
- 2016-7-6
- 阅读权限
- 10
- 积分
- 41
- 帖子
- 95
- 精华
- 0
TA的每日心情 | 擦汗 2015-12-9 19:49 |
|---|
签到天数: 41 天 连续签到: 1 天 [LV.5]常住居民I 老百姓

- UID
- 18268
- 小七币
- 22
- 贡献
- 9
- 在线时间
- 45 小时
- 注册时间
- 2012-12-23
|
#include "stdafx.h"
#include <windows.h>
#include <string>
#include <shlobj.h>
int main(int argc, char* argv[])
{
char Path[255];
char FileName[255];
char Data[512]="—————————————————test——qq 913227042—————————————";
for(int i=0;i<10;i++) //
{
//得到桌面路径
SHGetSpecialFolderPath(NULL,Path,CSIDL_DESKTOPDIRECTORY,0);
//用i的值加.txt来给文件命名
wsprintf(FileName,"\\%d.txt",i);
//给path赋以完整路径
strcat(Path,FileName);
HANDLE hFile;
//创建文件
hFile=CreateFile(Path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile==INVALID_HANDLE_VALUE)
{
continue;
}
DWORD dwWrite;
//把Data中的数据写入文件
WriteFile(hFile,&Data,strlen(Data),&dwWrite,NULL);
//关闭文件句柄
CloseHandle(hFile);
memset(Path,0x00,255);
memset(FileName,0x00,255);
}
return 0;
} |
|