News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

FileSystem parse

Started by oex, March 30, 2010, 11:54:43 PM

Previous topic - Next topic

oex

I am browsing the filesystem with my app and it gets to a folder named in Chinese '政治清明' findnextfile returns '????' and it fails.... how do I fix this?

???? are wildcard characters but:

a) findfirstfile returns INVALID_HANDLE_VALUE when I pass the folder name ie c:\????\* wildcards so I cant view folder contents
b) This is not very usefull if I want the folder name
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

joemc

forgive me for not reading the entire code, have you tried FindFirstFileW ?

oex

#2
ok findfirstfileW will work....

OK simpler question then.... How do I pass a unicode string? Currently I'm calling the function with chr$("c:\path\*")

EDIT: OK found it.... \masm32\macros\umacros.asm :lol who would have thought that's what the other macros file I hadnt used yet was for
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

oex

Doh! This isnt as easy as I expected.... I have used WSTR to create a string 'c:\*'

Printed it in a MessageBoxW to make sure it works (and it does)

Then fed it to FindFirstFileW function which *of course* errors and curses at me....

.data
WSTR    DriveX, "c:\*"

.code
invoke  MessageBoxW,0,ADDR DriveX,ADDR DriveX,MB_OK

LOCAL wfd:WIN32_FIND_DATA

invoke FindFirstFileW,ADDR DriveX,ADDR wfd
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Gunner

If you are using the unicode apis, then make sure you are using the unicode structures where appropriate:

Requirements
Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header WinBase.h (include Windows.h)
Unicode and ANSI names WIN32_FIND_DATAW (Unicode) and WIN32_FIND_DATAA (ANSI)
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

oex

Nice 1 ty, just did this in between posts and came back to find out if I was cheating :lol

WIN32_FIND_DATA2 STRUCT
  dwFileAttributes      DWORD      ?
  ftCreationTime        FILETIME <>
  ftLastAccessTime      FILETIME <>
  ftLastWriteTime       FILETIME <>
  nFileSizeHigh         DWORD      ?
  nFileSizeLow          DWORD      ?
  dwReserved0           DWORD      ?
  dwReserved1           DWORD      ?
  cFileName             BYTE MAX_PATH*2 dup(?) <------
  cAlternate            BYTE 14 dup(?)
WIN32_FIND_DATA2 ENDS


Will use WIN32_FIND_DATAW instead

As one might expect these unicode symbols are all foreign to me :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

oex

@Hutch: WIN32_FIND_DATAW doesnt appear to be in windows.inc

I'm guessing it is:

WIN32_FIND_DATAW STRUCT
  dwFileAttributes      DWORD      ?
  ftCreationTime        FILETIME <>
  ftLastAccessTime      FILETIME <>
  ftLastWriteTime       FILETIME <>
  nFileSizeHigh         DWORD      ?
  nFileSizeLow          DWORD      ?
  dwReserved0           DWORD      ?
  dwReserved1           DWORD      ?
  cFileName             WORD MAX_PATH dup(?)
  cAlternate            BYTE 14 dup(?) <---- Not sure what happens here?
WIN32_FIND_DATAW ENDS

Cant find the structure on the M$ website

http://www.masm32.com/board/index.php?topic=12654.msg99153#msg99153
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Gunner

this is from the header files:
typedef struct _WIN32_FIND_DATAA {
    DWORD dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD nFileSizeHigh;
    DWORD nFileSizeLow;
    DWORD dwReserved0;
    DWORD dwReserved1;
    CHAR   cFileName[ MAX_PATH ];
    CHAR   cAlternateFileName[ 14 ];
#ifdef _MAC
    DWORD dwFileType;
    DWORD dwCreatorType;
    WORD  wFinderFlags;
#endif
} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
typedef struct _WIN32_FIND_DATAW {
    DWORD dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD nFileSizeHigh;
    DWORD nFileSizeLow;
    DWORD dwReserved0;
    DWORD dwReserved1;
    WCHAR  cFileName[ MAX_PATH ];
    WCHAR  cAlternateFileName[ 14 ];
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv