进程问题

C_SDNLANGMINGFENG 2011-11-04 09:15:07
GetCurrentDirectory(),这个函数是获得当前进程的目录。

我想知道目录的内容都有哪些?

目录的作用都那些啊?
...全文
89 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
luciferisnotsatan 2011-11-04
  • 打赏
  • 举报
回复
MSDN

Listing the Files in a Directory
The following example calls FindFirstFile, FindNextFile, and FindClose to list the files in a specified directory.


Note that the only limitation on the number of files a directory can contain is the storage capacity of the disk.


#define _WIN32_WINNT 0x0501

#include <windows.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
char DirSpec[MAX_PATH]; // directory specification
DWORD dwError;

printf ("Target directory is %s.\n", argv[1]);
strncpy (DirSpec, argv[1], strlen(argv[1])+1);
strncat (DirSpec, "\\*", 3);

hFind = FindFirstFile(DirSpec, &FindFileData);

if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid file handle. Error is %u\n", GetLastError());
return (-1);
}
else
{
printf ("First file name is %s\n", FindFileData.cFileName);
while (FindNextFile(hFind, &FindFileData) != 0)
{
printf ("Next file name is %s\n", FindFileData.cFileName);
}

dwError = GetLastError();
FindClose(hFind);
if (dwError != ERROR_NO_MORE_FILES)
{
printf ("FindNextFile error. Error is %u\n", dwError);
return (-1);
}
}
return (0);
}
quwei197874 2011-11-04
  • 打赏
  • 举报
回复
自己调用一下不就啥都清楚了吗
bruceteen 2011-11-04
  • 打赏
  • 举报
回复
这个函数是获得当前进程的目录
--- 错,这个函数是获得进程的当前目录


我想知道目录的内容都有哪些?
目录的作用都那些啊?
--- 你在说什么呀,每个字我都认识,就是不知道你想说什么
qq120848369 2011-11-04
  • 打赏
  • 举报
回复
getcwd获取当前进程目录。
chdir改变当前进程目录。
opendir+readdir遍历任意目录。
赵4老师 2011-11-04
  • 打赏
  • 举报
回复
在cmd窗口里面输入以下命令:
cd /d d:\
tasklist
在tasklist运行时,
当前目录就是D:\
即工作目录_getcwd
目录中的内容请输入命令
dir
查看

C_SDNLANGMINGFENG 2011-11-04
  • 打赏
  • 举报
回复

我想知道目录的内容都有哪些?
目录的作用都那些啊?
--- 你在说什么呀,每个字我都认识,就是不知道你想说什么

不是说获得是进程的当前目录吗?那么目录总得有内容吧,那么这些内容都是什么呢?具体函数又是什么呢?
C_SDNLANGMINGFENG 2011-11-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bruceteen 的回复:]
这个函数是获得当前进程的目录
--- 错,这个函数是获得进程的当前目录


这两个有什么区别吗?我怎么读起来觉得一样呢?

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧