- 积分
- 72
- 最后登录
- 2014-10-7
- 阅读权限
- 20
- 积分
- 72
- 帖子
- 96
- 精华
- 0
TA的每日心情 | 怒 2014-10-7 13:12 |
|---|
签到天数: 45 天 连续签到: 1 天 [LV.5]常住居民I 菜鸟入门

- UID
- 17266
- 小七币
- 85
- 贡献
- 0
- 在线时间
- 80 小时
- 注册时间
- 2012-11-26
|
本帖最后由 君子坦蛋蛋 于 2012-12-27 17:17 编辑
课堂作业:文件的创建和删除
不存在:
已存在:
代码:
#include "stdafx.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
if( CreateDirectory("C:\\Documents and Settings\\Owner\\桌面\\嘿嘿交作业", NULL) == 1 )
{
MessageBox(NULL, "创建成功!", "温馨提示", MB_OK);
}
else
{
RemoveDirectory("C:\\Documents and Settings\\Owner\\桌面\\嘿嘿交作业");
MessageBox(NULL, "桌面存在该文件夹,已成功删除!", "温馨提示", MB_OK);
}
return 0;
}
课后作业:获取当前路径并改变路径
获取当前路径:
改变路径:
代码:
#include "stdafx.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
char fPath[MAX_PATH];
char nPath[MAX_PATH] = "C:\\Documents and Settings\\Owner\\桌面\\嘿嘿交作业";
char mPath[MAX_PATH] = "1.exe";
GetModuleFileName(NULL, fPath, MAX_PATH);
int i = MessageBox(NULL, fPath, "当前路径", MB_OK);
if( i = IDOK )
{
strcat(nPath, "\\1.exe");
CopyFile(fPath, nPath, true);
MessageBox(NULL, nPath, "改变路径", MB_OK);
}
return 0;
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|