Hello Everybody

Do anyone know the code for separating this string. I got it in Buffer0, I don't want the * , * in the new buffers but the * , * is the key to doing the separating...

Buffer0 got ....... Smith,2207
Buffer1 to be ... Smith
Buffer2 to be ... 2207

I got the code for it somewhere and have done it before but it will take a month to find it and i don't remember how to do it... Believe me i founded a lot of other little things while working today but i can't find or remember this for the life of me.....I would be very grateful for the help.

Thanks in advance

.............................................................................
PS: Could someone tell me what Recursive mean. My guest is not realizing fully on the API to compete it mission. I been looking into Qweerdy *Enum File* and it is very educational, not to hard to follow but not that easy either if you don't know all the meanings.
Posted on 2002-05-19 01:39:24 by cmax
'Recursive' is when a function calls itself. When you do this, you have to be very careful about how the data is passed, and at exactly what point you call the function. I won't explain too much more than that right now, i might not explain it very simply, i might confuse you more :)
Posted on 2002-05-19 07:33:44 by sluggy
cmax,

Without knowing exactly what you are doing with the seperated components of the string, the simplest way would be to allocate a number of buffers big enough for each string, then loop through the source string and jump to the next loop when you find the seperator.

This is a static approach to the problem. If you need a more dynamic approach you would need to allocate enough memory for an array and loop through the array one DWORD at a time.

Recursion means when a procedure calls itself one or more times. It can be a dangerous style of coding unless you undersatand what you are doing but the basics are you must have some method of differentiating what is passed to the same procedure so that you don't get an infinite recursion. This will cause a stack fault when the stack limit is exhausted.

Regards,

hutch@movsd.com
Posted on 2002-05-19 08:29:49 by hutch--
Thank sluggy, that a perfect explantion. Now i know.
Thanks Hutch, I got the full ideal of what to do, I don't need to find my old file now. Old Qweerdy, took on the challenge and seem to really have it together with his EMUM File, I did all kinds of stuff with-it just to see if it would miss and it did not, Great Work. It's the perfect example.

Hutch, I know i must be getting preety good at it now because i get board that because i can remember things by hard or can't think of a solution with in a hour or two.... it use to take weeks...Now some time i just run through things just by remembering what was said on posts or the M32.lib , and it usually comes out perfect.
Posted on 2002-05-19 10:52:18 by cmax
cmax:

Nice to know someone benefitted from my code! I must say the original code has been updated quite a bit since I posted it, but I don't think it became any easier to read.

About your other question, things would be a lot easier if it is OK to change the data in buffer0. Also, I'm assuming you want NULL-terminated strings. In that case this would work:



mov esi,offset Buffer0
StartLoop:
mov edx,esi
@@:
mov al,[esi]
inc esi
cmp al,0
je EndLoop
cmp al,","
jne @B
mov [esi-1],0
; -----------
; Here edx holds a pointer to one of the strings
; -----------
cmp byte ptr [esi],0
jne StartLoop
EndLoop:
; Make sure to process the last item here! Pointer in edx.
; You don't have to worry about this if your string has a "," at the end.

Posted on 2002-05-19 11:09:49 by Qweerdy
I ripped your EnumFiles apart, i think i took out call myself... and i call pat *BUST-IT-ALL-UP*

I like it because when it do shelloperation and plain delete file that Window window thing comes in sometimes and show to the users what is being deleted...You know that progress bar or something...With your file i put in 200 or more files that i want to delete and GUEST WHAT...It delete it with no window flags as i go to do other things on the computer with no Progress Bar and no other visual affect on the system as it dose its job....I Love That. I got it do all that i want to get rid of but the cookies, but that seems to be hell as it is....

Temporary Internet Files i have to figure out a better way. Thsoe sub folders change if just founded that out...

I think i will end up going with the your full versions, with your permit latter,but by nature i always break things down, that how i learned to read and understand ASM I do this always...Here what i did so far....


; (c) 2002 by Qweerdy. Beta release.
;
.386
.model flat,stdcall
option casemap:none


include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib



WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
Callback proto :DWORD,:DWORD,:DWORD
EnumFiles proto :DWORD,:DWORD,:DWORD,:DWORD

.const
PatternBufferSize equ 2 * MAX_PATH ; Size of buffer for full filenames. Must be large enough.

.const
fRecursive equ 1
fDirBefore equ 2
fDirAfter equ 4
fParamIsLength equ 8



.data
sBustIEw db "C:\WINDOWS\Temporary Internet Files\Content.IE5\wtctktw7\",0
sBustIEu db "C:\WINDOWS\Temporary Internet Files\Content.IE5\us04oty5\",0
sBustIEg db "C:\WINDOWS\Temporary Internet Files\Content.IE5\gdef8dwf\",0
sBustIE0 db "C:\WINDOWS\Temporary Internet Files\Content.IE5\0x6zc5ar\",0

sBustIEALL db "C:\WINDOWS\Temporary Internet Files\",0

sBustHISTORY1 db "C:\WINDOWS\History\History.ie5\",0


sBustRECENT db "C:\WINDOWS\Recent\",0
sBustTEMP db "C:\WINDOWS\Temp\",0


hFile dd ?
fn db "C:\Windows\Desktop\dirtest.txt",0
szError db "Oops, an error occured!",0
crlf db 13,10
tmp dd ?

.code

; ---------------------------------------------------------------------------

start:

invoke EnumFiles,addr sBustIEw,fRecursive+fDirBefore+fParamIsLength,Callback,0
invoke EnumFiles,addr sBustIEu,fRecursive+fDirBefore+fParamIsLength,Callback,0
invoke EnumFiles,addr sBustIEg,fRecursive+fDirBefore+fParamIsLength,Callback,0
invoke EnumFiles,addr sBustIE0,fRecursive+fDirBefore+fParamIsLength,Callback,0

invoke EnumFiles,addr sBustRECENT,fRecursive+fDirBefore+fParamIsLength,Callback,0
invoke EnumFiles,addr sBustTEMP,fRecursive+fDirBefore+fParamIsLength,Callback,0


invoke ExitProcess,0



; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................

Callback proc pPattern:dword,pfd:dword,Param:dword

local bw:dword

invoke StrLen,pPattern ; This code returns the complete path
mov ebx,eax
mov esi,pPattern


PUSH pPattern
CALL DeleteFileA


;;invoke MessageBox,0,pPattern,0,0

; invoke WriteFile,hFile,esi,ebx,addr bw,0
; invoke WriteFile,hFile,addr crlf,2,addr bw,0
ret

Callback endp
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................
; ..............................................








EnumFiles proc pFileSpec:dword,Flags:dword,pCallback:dword,Param:dword

local pPattern:dword
local pPatternFn:dword
local NoPath:byte
local hff:dword
local fd:WIN32_FIND_DATA
local pLocalFn:dword
local lLocalFn:dword

; .............................................. Allocate room for the search pattern

PUSH PatternBufferSize
PUSH GMEM_FIXED
CALL GlobalAlloc

.if eax==0
ret
.endif
mov pPattern,eax

; .............................................. Get the path portion of the search pattern
mov esi,pFileSpec
@@:
mov al,
inc esi
cmp al,"\"
je HasPath
cmp al,"/"
je HasPath
cmp al,0
jne @B
; ..............................................
HasNoPath:
mov NoPath,1
invoke GetCurrentDirectory,PatternBufferSize,pPattern
or eax,eax
jz Error
cmp eax,PatternBufferSize-1
jg Error
jmp CompletePath
; ..............................................
; ..............................................
; ..............................................
HasPath:
mov NoPath,0
push esi
push edi

xor ecx, ecx ; zero counter
mov esi, pFileSpec
mov edi, pPattern

@@:
mov al, ; read byte from address in esi
inc esi
inc ecx ; increment counter
cmp al, 0 ; test for zero
je gfpOut ; exit loop on zero
cmp al, "\" ; test for "\"
jne nxt1 ; jump over if not
mov edx, ecx ; store counter in ecx = last "\" offset in ecx
nxt1:
mov , al ; write byte to address in edi
inc edi
jmp @B

gfpOut:
add edx, pPattern ; add destination address to offset of last "\"
mov , al ; write terminator to destination

pop edi
pop esi
; ..............................................
; ..............................................
; ..............................................
CompletePath:

invoke StrLen,pPattern
test Flags,fParamIsLength
jz @F
mov Param,eax
and Flags,(not fParamIsLength)
@@:
push eax ; Length of Path is pushed here <----
add eax,pPattern
cmp byte ptr ,"\"
je PathDone
cmp byte ptr ,"/"
je PathDone
mov word ptr ,005ch ; db "\",0
inc eax
PathDone:
mov pPatternFn,eax

; .............................................. Get the filename portion of the pattern
invoke StrLen,pFileSpec
pop ebx ; And popped here <----
mov edi,pPatternFn
.if NoPath
mov esi,pFileSpec
.if byte ptr ==0
mov dword ptr ,002a2e2ah ; db "*.*",0
.else
mov esi,pFileSpec
mov ecx,eax
inc ecx
rep movsb
.endif
.else
.if eax==ebx ; If there was no filename
mov dword ptr ,002a2e2ah ; db "*.*",0
.endif
.endif

; .............................................. Find the first file

invoke FindFirstFile,pPattern,addr fd
cmp eax,INVALID_HANDLE_VALUE
je Error
mov hff,eax

cmp pCallback,0
je Error

; .............................................. Start of the file loop!
FileLoop:
; .............................................. If it's a directory and we're doing recursion
; .............................................. ignore it for now.

test fd.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY
jz @F
test Flags,fRecursive
jnz SkipCallback
@@:
; .............................................. Append the filename to the path
lea esi,fd.cFileName
mov edi,pPatternFn
@@:
mov al,
inc esi
mov ,al
inc edi
cmp al,0
jne @B
; .............................................. Do the callback
mov eax,pCallback
push Param
lea esi,fd
push esi
push pPattern
call eax
SkipCallback:

; .............................................. Find the next file
invoke FindNextFile,hff,addr fd
or eax,eax
jnz FileLoop
invoke CloseHandle,hff ; End of the file loop!
; .............................................. If we don't need to do recursion, skip to the end.
test Flags,fRecursive
jz Done
; .............................................. We want to find ALL dirs, not just those matching
; .............................................. the original pattern.
mov edi,pPatternFn
mov dword ptr ,002a2e2ah ; = "*.*", 0
pop edi

Done:
invoke GlobalFree,pPattern
invoke GlobalFree,pLocalFn
mov eax,-1
ret
; ..............................................
Error:
invoke GlobalFree,pPattern
invoke GlobalFree,pLocalFn
xor eax,eax
ret

EnumFiles endp






end start
Posted on 2002-05-19 11:50:02 by cmax