阅读:1727回复:6
driver中如何将短文件名转换为长文件名?
就是把8+3的DOS文件名转换为长文件名。比如将c:\\progra~1\\readme.txt转换为c:\\program files\\readme.txt
Thx! [编辑 - 4/9/02 作者: Netguy] |
|
沙发#
发布于:2002-04-10 10:23
在VxD里面有一个函数可以直接转换,NT下可以用ZwQueryDirectoryFile来找出她的短文件名。
|
|
板凳#
发布于:2002-04-10 20:31
That\'s an operation that is quite common in a File System filter driver.
You should be able to use it also in a device diver. Assuming that you already have a FULL path name (starting from the root) and not a relative name, you can do the following: - Parse each component of the name. Get the name of the file/directory you want the long file name for and the name of the directory in which this file/directory resides. Example: 1st pass: directory name: \\ file/directory name: PROGRA~1 2nd pass: directory name: \\PROGRA~1\\ file/directory name: readme.txt ... - For each component, open the directory using ZwCreateFile or IoCreateFileSpecifyDeviceObjectHint if you are in a FS Filter. If you are a FS filter, you can specify the VDO you are attached to with IoCreateFileSpecifyDeviceObjectHint. This will avoid reentrency in your filter. If you are not in the FS stack, then ZwCreateFile will be fine. - Then, send a ZwQueryDirectoryFile (..., FileBothDirectoryInformation, ...) and precise your file/directory name for the FileName parameter. Note that you can also use the FileNamesInformation class. - You will then get a FILE_BOTH_DIR_INFORMATION structure with the long file name inside for the file you have specified (FileName field). - Then, rebuild the full long file name with the long file names you have obtained. 这个是我在news.microsoft.com上看到的这个问题的回答,希望对你有些帮助吧 :P :P :P |
|
|
地板#
发布于:2002-07-09 17:21
呵呵,微软新闻组上的那个也是我问的呀
我的这个driver是从FileMon改过来的,应该算个FS Filter。我查了一下,IoCreateFileSpecifyDeviceObjectHint这个好象是WinXP的IFS Kit中新增的(参看http://www.microsoft.com/DDK/IFSkit/XPPortingGuide.asp),在Win2K的ntoskrnl.exe中没有导出这个函数。 怎么办?只好用ZwCreateFile试试看是否不蓝屏? [编辑 - 7/9/02 by Netguy] [编辑 - 7/9/02 by Netguy] |
|
地下室#
发布于:2002-07-09 17:22
呵呵,微软新闻组上的那个也是我问的呀 好老的帖子,呵呵 :( :( :( |
|
|
5楼#
发布于:2002-07-10 15:54
老没关系,我的问题还没有解决呀
[quote]呵呵,微软新闻组上的那个也是我问的呀 |
|
6楼#
发布于:2002-07-10 15:54
老没关系,我的问题还没有解决呀
好老的帖子,呵呵 :( :( :( |
|