CompactFrameworkでアプリケーションを開発します。WindowsMobile6.x用のnet3.5c#。
アプリケーションをアンインストールする際に、レジスター内のいくつかのキーとその内容を含むフォルダーを削除したいと思います。
インターネットを検索すると、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;
}
ありがとう