Solved

Filename codepage conversion

Posted on 2004-04-16
7
415 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:ccrdude
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:mbprogrammer
Comment Utility
Use Far to Delete them ;)
you can download it fom here : www.farmanager.com
0
 
LVL 2

Author Comment

by:ccrdude
Comment Utility
Thanks, but - as I said - I could already delete them from the command line. I want/need to delete them from my own code ;)
0
 
LVL 4

Expert Comment

by:mbprogrammer
Comment Utility
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.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:ccrdude
Comment Utility
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 :(
0
 
LVL 4

Expert Comment

by:mbprogrammer
Comment Utility
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
0
 
LVL 4

Accepted Solution

by:
mbprogrammer earned 500 total points
Comment Utility
or this one : SetFileApisToOEM .
0
 
LVL 2

Author Comment

by:ccrdude
Comment Utility
Excellent! That was exactly what I was looking for, but couldn't find. Thank you!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now