Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3981188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:22:49+00:00 2026-05-20T05:22:49+00:00

Develop an application on Compact Framework. net 3.5 c# for Windows Mobile 6.x. In

  • 0

Develop an application on Compact Framework. net 3.5 c# for Windows Mobile 6.x.

In uninstalling the application would like to remove some keys in the register and a folder with its contents.

Searching the internet I met other tips on how to use the SetupDLL Cab project and discovered that I have to create a c + + project, implement the methods

Install_Init – called before installation begins.

Install_Exit – called after an application is installed.

Uninstall_Init – called before an application is uninstalled.

Uninstall_Exit – called after an application is uninstalled.

as described in the link:
http://www.christec.co.nz/blog/archives/119

Well my great difficulty is to remove a folder and all its contents and delete a key in the register using c++.

I’ve tried several methods to find on the internet but none even compiles.

Please, now more than 3 days I’m still unable to solve this problem.

Sample method in C++ to delete recursive directory:

    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;
}

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:22:50+00:00Added an answer on May 20, 2026 at 5:22 am

    The big problem with what I’m seeing in your code is that it’s all ASCII (char, strcat, etc) and CE uses Unicode. I also don’t fully understand your passing of things like a “string” type – you must be importing some things that aren’t shown.

    What you really need is to call FindFirstFile in your path, then iteratively call DeleteFile and FindNextFile until there are no more files. Once the folder is empty, call RemoveDirectory.

    This implementation looks reasonable (though the “IsDots” stuff can be omitted for CE).

    EDIT
    Turns out that the implementation linked above has a bug when actually used in a Unicode environment. I’ve fixed it as well as made it compatible for CE (while maintaining desktop compatibility). Here’s teh updated version:

    BOOL DeleteDirectory(TCHAR* sPath) {
       HANDLE hFind;    // file handle
       WIN32_FIND_DATA FindFileData;
    
       TCHAR DirPath[MAX_PATH];
       TCHAR FileName[MAX_PATH];
    
       _tcscpy(DirPath, sPath);
       _tcscat(DirPath, _T("\\*"));    // searching all files
       _tcscpy(FileName, sPath);
       _tcscat(FileName, _T("\\"));
    
       // find the first file
       hFind = FindFirstFile(DirPath,&FindFileData);
       if(hFind == INVALID_HANDLE_VALUE) return FALSE;
       _tcscpy(DirPath,FileName);
    
       bool bSearch = true;
       while(bSearch) {    // until we find an entry
          if(FindNextFile(hFind,&FindFileData)) {
             _tcscat(FileName,FindFileData.cFileName);
             if((FindFileData.dwFileAttributes &
                FILE_ATTRIBUTE_DIRECTORY)) {
    
                // we have found a directory, recurse
                if(!DeleteDirectory(FileName)) {
                    FindClose(hFind);
                    return FALSE;    // directory couldn't be deleted
                }
                // remove the empty directory
                RemoveDirectory(FileName);
                 _tcscpy(FileName,DirPath);
             }
             else {
                if(FindFileData.dwFileAttributes &
                   FILE_ATTRIBUTE_READONLY)
                    SetFileAttributes(FindFileData.cFileName, 
                        FindFileData.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
                      if(!DeleteFile(FileName)) {    // delete the file
                        FindClose(hFind);
                        return FALSE;
                   }
                   _tcscpy(FileName,DirPath);
             }
          }
          else {
             // no more files there
             if(GetLastError() == ERROR_NO_MORE_FILES)
             bSearch = false;
             else {
                // some error occurred; close the handle and return FALSE
                   FindClose(hFind);
                   return FALSE;
             }
    
          }
    
       }
       FindClose(hFind);                  // close the file handle
    
       return RemoveDirectory(sPath);     // remove the empty directory
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop applications for the PocketPC platform (.NET Compact Framework 2.0 and higher), and
I have to develop an application using C#.net that has to be run once
We are using c++ to develop an application that runs in Windows CE 4
I want to develop application that my database is not in the localhost, like
I develop an application on PyQt, I like the signal-slot model, but is there
I develop an application on WPF. I have recognized that some parts of the
We develop Win32 application that access to SQL 2005 database through Linq to SQL.
I have to develop an application which parses a log file and sends specific
As you develop an application database changes inevitably pop up. The trick I find
I need to develop an application which stores data in a SQL Server 2005

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.