Solved

Filename codepage conversion

Posted on 2004-04-16
7
427 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 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