Filename codepage conversion

Situation: a trojan has created 100 folders on the desktop (Windows 98). The problem: it used some special characters.

Neither deleting, moving or renaming works - all attempts end in Windows error 1026 (which usually means network problems or not enough disk space, but that is not the case).

The only working way I found is using a command window, copying a folder name from the 'dir' results, and using 'rmdir' with that copied folder name. While this works, in the end I need a Windows program instead of manual instructions for this.

Using Windows.FindFirstFile,FindNextFile,FindClose (or the Delphi ones FindFirst, FindNext, FindClose) returns slighty different folder names (even pasting the copied 'dir' folder name into a Windows window does return a different name). Therefore I'ld say the problem is a different codepage. So I first tried to convert codepages from 437 - 850 - 1252 in all directions (later about a dozen different to no avail), but this didn't return any useful folder name.
I also tried a bunch of different removal procedures with all filename combinations - RmDir, RemoveDir, RemoveDirectory, DeleteFile, RenameFile, ShFileOperation - to no avail.

Well, maybe my codepage conversion isn't working (I convert to Unicode with one codepage and back with another). Does anyone know how to convert filename text from a dos box to valid Windows filename text (if the text contains codepage specific characters)? A conversion that would allow me to actually access the folder with RemoveDirectory?

PS: Accidently posted this in Programming as well... whoever solves this quickly will get points from both questions.
Who is Participating?
mbprogrammerConnect With a Mentor Commented:
or this one : SetFileApisToOEM .
Use Far to Delete them ;)
you can download it fom here :
ccrdudeAuthor Commented:
Thanks, but - as I said - I could already delete them from the command line. I want/need to delete them from my own code ;)
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

In C the findfirst and findnext functions return the dos name of a file.
they are in dos.h header file.
In Delphi try these : FindFirstFile , FindNextFile , ... . I didn't test them in such situation.
ccrdudeAuthor Commented:
Well, I appreciate your suggestion, but as you can read above, the name returned by those is not the one accepted by RmDir or RemoveDir. Works fine for file/folder names with only 'normal' characters, but not for those :(
try this before using them : SetFileApisToANSI

SetFileApisToANSI :
  The SetFileApisToANSI function causes a set of Win32 file functions to use the ANSI character set code page. This function is useful for 8-bit console input and output operations
ccrdudeAuthor Commented:
Excellent! That was exactly what I was looking for, but couldn't find. Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.