Hi everybody..!

Here's a little problem I really don't understand :? , though the solution must be quite simple... :oops:

My aim is to create a file for any purpose, and then delete it.

program Myprog;


#include( "w.hhf" )

const
MyFile:string:="Hello.txt";
endconst;

begin Myprog;

w.CreateFile
(
MyFile,
w.GENERIC_READ,
w.FILE_SHARE_READ,
NULL,
w.CREATE_NEW,
w.FILE_ATTRIBUTE_NORMAL,
NULL
);
w.CloseHandle(MyFile);
w.DeleteFile(MyFile);

end Myprog;



The compiler refuses to work, saying :

Error in file ... at line 21 :
Type mismatch (string parameter illegal).
Near: << ) >>

That line concerns the CloseHandle call, but I can't see what is wrong !?!?!
...as the following DeleteFile call, which written in the same pattern, generates no problem.

The fact is that if I merely bypass the CloseHandle call, then at run-time, the DeleteFile doesn't operate (Hello.txt remains).
What did I miss ???

Thanks a lot for answers...

Juan.
Posted on 2004-09-08 02:21:36 by Juan
OK...
...after checking the w.hhf include file, I discovered that both CreateFile and Deletefile wait for a string-type param., when CloseHandle waits for a dword-type param.

so my correct code looks like :
program Myprog;


#include( "w.hhf" )

const
MyFile:string:="Hello.txt";
endconst;

static
Fich1:dword;
endstatic;

begin Myprog;

w.CreateFile
(
MyFile,
w.GENERIC_READ,
w.FILE_SHARE_READ,
NULL,
w.CREATE_NEW,
w.FILE_ATTRIBUTE_NORMAL,
NULL
);
mov (eax, Fich1);
w.CloseHandle(Fich1);
w.DeleteFile(MyFile);

end Myprog;


and seems now to work fine...
Nevertheless, any suggestion is welcome...

until soon,
bye...

Juan.
Posted on 2004-09-08 02:43:59 by Juan