请教关于WinExec的问题,马上揭贴

ControlCoder45 2006-10-12 09:26:17
我想执行cmd命令,改变文件/文件夹权限

对于ntfs文件系统才有效

我想判断当前的文件系统是fat/fat32还是ntfs应该怎么做啊??????

如果是ntfs就执行下面的

下面的cmd命令要在当前程序运行目录下执行才能成功

所以我想是否需要先执行一个cd命令?

cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>
Cacls web /t /e /c /g ASPNET:f

这样可以吗?

cmd命令下换行怎么写的啊?

是否还有更简单的方法?

如果先WinExec("cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>")
在WinExec("Cacls web /t /e /c /g ASPNET:f")
这样可以吗?

...全文
295 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wltg2001 2006-10-13
  • 打赏
  • 举报
回复
楼主的问题是想问:如何用WinExec来执行多个命令,我想建一个批处理应该可以。
zhucde 2006-10-13
  • 打赏
  • 举报
回复
你要执行此句干什么?

WinExec("cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>")

一是没必要, 二是如果想设置默认默认,可以用API, SetCurrentDirectory
ControlCoder46 2006-10-12
  • 打赏
  • 举报
回复
ControlCoder46 2006-10-12
  • 打赏
  • 举报
回复
我在dos命令里直接输入这样的两行却可以
ControlCoder46 2006-10-12
  • 打赏
  • 举报
回复
试过
CString strCmdStr = "Cacls ";
strCmdStr += strFileName ;
strCmdStr += " /t /e /c /g ASPNET:";
strCmdStr += strRight;

CString strPath;
CUitility util;
util.GetCurrentDir(strPath);
CString cdCmdStr="cd ";
cdCmdStr += strPath;

WinExec(cdCmdStr,SW_HIDE);
WinExec(strCmdStr,SW_HIDE);

这样

不行!
DentistryDoctor 2006-10-12
  • 打赏
  • 举报
回复
用WinExec,如果路径中有空格,应该用""将路径括起来。
如果可能,请尽可能用CreateProcess来替换。

WinExec("cd \"C:\\Documents and Settings\\Administrator\\桌面\\Soft\\InstallUpdate\\Debug\"", ...);

WinExec("Cacls web /t /e /c /g ASPNET:f", ...);
ControlCoder46 2006-10-12
  • 打赏
  • 举报
回复
ControlCoder45 2006-10-12
  • 打赏
  • 举报
回复

ding
ControlCoder45 2006-10-12
  • 打赏
  • 举报
回复
我用空格把cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug Cacls web /t /e /c /g ASPNET:f
弄成上面这个样子

运行也不成功

帮帮忙啊
ControlCoder45 2006-10-12
  • 打赏
  • 举报
回复
如果先WinExec("cd C:\Documents and Settings\Administrator\桌面\Soft\InstallUpdate\Debug>")
在WinExec("Cacls web /t /e /c /g ASPNET:f")
这样可以吗?

------------------

试过了,这样无法成功


DentistryDoctor(不在无聊中无奈,就在沉默中变态) ( ) 信誉:194 Blog
-------------------

有详细的例子吗?我是新手
DentistryDoctor 2006-10-12
  • 打赏
  • 举报
回复
WinExec没法判断文件系统吧?

GetVolumeInformation

The GetVolumeInformation function retrieves information about a file system and volume that have a specified root directory.


BOOL GetVolumeInformation(
LPCTSTR lpRootPathName,
LPTSTR lpVolumeNameBuffer,
DWORD nVolumeNameSize,
LPDWORD lpVolumeSerialNumber,
LPDWORD lpMaximumComponentLength,
LPDWORD lpFileSystemFlags,
LPTSTR lpFileSystemNameBuffer,
DWORD nFileSystemNameSize
);

lpFileSystemNameBuffer
[out] Pointer to a buffer that receives the name of the file system (such as the FAT file system or the NTFS file system).
nFileSystemNameSize
[in] Length of the file system name buffer, in TCHARs. This parameter is ignored if the file system name buffer is not supplied.

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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