Solved

Filename codepage conversion

Posted on 2004-04-16
7
418 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
ID: 10848772
Use Far to Delete them ;)
you can download it fom here : www.farmanager.com
0
 
LVL 2

Author Comment

by:ccrdude
ID: 10853513
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
ID: 10854629
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:ccrdude
ID: 10854850
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
ID: 10858584
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
ID: 10858612
or this one : SetFileApisToOEM .
0
 
LVL 2

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 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

16 Experts available now in Live!

Get 1:1 Help Now