如何用SDK实现如下程序:运行后自动在指定目录生成一个mp3文件(此文件是事先给定的)?
解决方案 »
- 关于文件读取文件,转变文件内字符串的格式
- 天气预报查询
- 高分求助,VC关于xml文件的生成和对xml文件的解析(有附件)
- .lib里面怎么添加资源?
- 我想了解一下cup和内存的使用情况,请介绍一个软件给我吧。谢谢!
- ADO编程中,在获得结果集同时,还能通过adParamOutput(输出类型参数)如何得到返回值?
- 由谁能说说GetPrivateProfileSectionNames第三个参数的使用方法
- SVN可以下载上传代码,但是看不到记录
- 窗口滚动出现的问题!
- 如何用CFile类读入一批数据(从文本文件中)?
- 请教一个让人郁闷的问题!
- 大家能留下你经常或者是学习VC时常用的网站吗~~~~留下网址的均有分~~~不够另开~~~
SHFileOperationCopies, moves, renames, or deletes a file system object. int SHFileOperation(
LPSHFILEOPSTRUCT lpFileOp
);
The MoveFile function moves an existing file or a directory, including its children. To specify how to move the file, use the MoveFileEx function. BOOL MoveFile(
LPCTSTR lpExistingFileName, // file name
LPCTSTR lpNewFileName // new file name
);
f.Open();
f.Write();
f.Close();
fopen
fread
fwrite
fclose
CreateFile
////////////////////////////////////////////////
HANDLE CreateFile(
LPCTSTR lpFileName, // pointer to name of the file
DWORD dwDesiredAccess, // access (read-write) mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
// pointer to security attributes
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile // handle to file with attributes to
// copy
);
fwrite(buffer,1,size,fp);
fclose(fp);如果还想将此文件生成在指定的路径下,也是可以的,有大把的API函数可以调用,比如
CreateDirectory, GetCurrentDirectory, GetSystemDirectory.......
FILE *fp = fopen("yourname.mp3","w+");
fwrite(buffer,1,size,fp);
fclose(fp);
然后:CreateDirectory, GetCurrentDirectory, GetSystemDirectory.......
ReadFile
WriteFile绝对够你用了。
fread
fwrite
fclose
HGLOBAL hgbRes = LoadResource(hModule, hResource);//load the resource
LPVOID lpRes = LockResource(hgbRes);//get a pointer to the resourceHANDLE hFile = CreateFile(...);
DWORD dwWritten;
WriteFile(hFile, lpRes, SizeofResource(hModule, hResource), dwWritten,NULL)//or
// you can use overlapped IO
CloseHandle(hFile);
如果你文件事先存在,把他拷贝过来就可以了SHFILEOPSTRUCT FileOp;
FileOp.hwnd = m_hWnd;
//执行文件操作
FileOp.wFunc = FO_DELETE;
SHFileOperation(&FileOp);
还是应该怎么写?