锁定文件夹中的问题 [英] Problem in Locking folder

查看:82
本文介绍了锁定文件夹中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我开发了一个锁定文件夹的应用程序。下面是我用来锁定文件夹的代码。通常代码工作正常如果文件夹/文件名不包含任何空格。(例如:文件夹名称 - 测试文件夹),如果文件夹名称是TestFolder,那么代码工作正常,文件夹被正确锁定。我可以帮助确切地说它出错了。



先谢谢。



Hello,

I have developed an application to lock the folder.Below is the code that i use for locking the folder.Normally the code works fine if the folder/file name doesnt contain any spaces.(Example: Folder Name - Test Folder) and if the folder name is TestFolder then the code works fine and the folder is locked properly.Can i help where exactly its going wrong.

Thanks in Advance.

char pass[15]="";
ofstream lfolder;
char folder[200]={0};
CString Foldername;
CString drive;
char tempfolder[200]={'0'};
char attributes[50]={'0'};

drive = "D:\\TestFolder";

sprintf_s(folder, "%s", drive);
strcpy(tempfolder, folder);

strcat(folder, "\\Desktop.ini");

lfolder.open(folder, ios::out);

lfolder << "[.shellClassInfo]" << endl;
lfolder << "CLSID = {2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}" << endl;

lfolder.close();

strcpy(attributes, "attrib +h +s ");
strcat(attributes, tempfolder);

WinExec(attributes, NULL);

推荐答案

您正在构建一个字符串,尝试通过WinExec()通过命令行操作设置特征。您需要构建命令行,以便文件名以双引号显示。例如,您为C:\\Test Folder构建的命令行是''attrib + h + s C:\\Test Folder'',它应该是''attrib + h + sC :\\Test Folder''。
You are building a string that attempts to set the characteristics with a command line operation via WinExec(). You need to build the command line so that the filename shows up in double quotes. For example the command line you are building for "C:\\Test Folder" is ''attrib +h +s C:\\Test Folder'' and it should be ''attrib +h +s "C:\\Test Folder"''.


这篇关于锁定文件夹中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆