在 Compact Framework 上开发应用程序。NET 3.5 c# 用于 Windows Mobile 6.x。
在卸载应用程序时,想删除注册表中的一些键和包含其内容的文件夹。
在网上搜索了其他关于如何使用SetupDLL Cab项目的提示,发现我必须创建ac++项目,实现方法
Install_Init - 在安装开始之前调用。
Install_Exit - 在安装应用程序后调用。
Uninstall_Init - 在卸载应用程序之前调用。
Uninstall_Exit - 在卸载应用程序后调用。
如链接中所述:http: //www.christec.co.nz/blog/archives/119
好吧,我最大的困难是删除一个文件夹及其所有内容,并使用 C++ 删除寄存器中的一个键。
我尝试了几种在互联网上查找的方法,但都没有编译。
请,现在超过3天我仍然无法解决这个问题。
C++ 中删除递归目录的示例方法:
bool RemoveDirectory(string path) {
if (path[path.length()-1] != '\\') path += "\\";
// first off, we need to create a pointer to a directory
DIR *pdir = NULL; // remember, it's good practice to initialise a pointer to NULL!
pdir = opendir (path.c_str());
struct dirent *pent = NULL;
if (pdir == NULL) { // if pdir wasn't initialised correctly
return false; // return false to say "we couldn't do it"
} // end if
char file[256];
int counter = 1; // use this to skip the first TWO which cause an infinite loop (and eventually, stack overflow)
while (pent = readdir (pdir)) { // while there is still something in the directory to list
if (counter > 2) {
for (int i = 0; i < 256; i++) file[i] = '\0';
strcat(file, path.c_str());
if (pent == NULL) { // if pent has not been initialised correctly
return false; // we couldn't do it
} // otherwise, it was initialised correctly, so let's delete the file~
strcat(file, pent->d_name); // concatenate the strings to get the complete path
if (IsDirectory(file) == true) {
RemoveDirectory(file);
} else { // it's a file, we can use remove
remove(file);
}
} counter++;
}
// finally, let's clean up
closedir (pdir); // close the directory
if (!rmdir(path.c_str())) return false; // delete the directory
return true;
}
谢谢