os :
microsoft windows 2000 [version 5.00.2195]
(c) 凯发k8官网下载客户端中心的版权所有 1985-2000 microsoft corp.
===================
#include <windows.h>
#include <stdio.h>
#define bufsize 4096
int main(int argc, char *argv[])
{
dword retval = 0;
bool success;
char buffer[bufsize] = "";
char *lppart[bufsize] = {null};
/*
retrieve a full path name for a file. the file does not need to exist.
提取文件的全名
如: 当前目录下的aa.c文件(当前目录为c:\win32),那么就可以得到为"c:\win32\aa.c"
*/
retval = getfullpathname("t1.c", bufsize, buffer, null);
if (retval == 0)
{
// handle an error condition.
printf ("getfullpathname failed with error %d.\n", getlasterror());
return (1);
}
else
printf("the full path name for the file test.txt is: %s\n", buffer);
// create a long directory name for use with the next two examples.
success = createdirectory("c:\\longdirectoryname", null); // no security attributes.
if (!success)
{
// handle an error condition.
printf ("createdirectory failed with error %d.\n", getlasterror());
return (1);
}
// retrieve the short path name.
retval = getshortpathname("c:\\longdirectoryname", buffer, bufsize);
if (retval == 0)
{
// handle an error condition.
printf ("getshortpathname failed with error %d.\n", getlasterror());
return (1);
}
else
printf("the short path name for the directory "
"c:\\longdirectoryname is: %s\n", buffer);
// retrieve the long path name.
retval = getlongpathname("c:\\longdi~1", buffer, bufsize);
if (retval == 0)
{
// handle an error condition.
printf ("getlongpathname failed with error %d.\n", getlasterror());
return (1);
}
else
printf("the long path name for the directory "
"c:\\longdirectoryname is: %s\n", buffer);
// clean up the directory.
success = removedirectory("c:\\longdirectoryname");
if (!success)
{
// handle an error condition.
printf ("removedirectory failed with error %d.\n", getlasterror());
return (1);
}
}
|
阅读(2087) | 评论(0) | 转发(0) |