I tried using CreateFile to open the win386.swp but it fails every time. GetLastError show a sharing violation. I know the file is in use when windows is running but does this message mean the file is impossible to open?
Thanks for any suggestions.

best regards,

czDrillard
Posted on 2002-02-23 23:35:52 by czDrillard
Test it Please:

;********************************************
.data
FileName db "c:\win386.swp"

.code
invoke CreateFile,addr FileName,GENERIC_READ,FILE_SHARE_READ or FILE_SHARE_WRITE ,NULL,OPEN_EXISTING,NULL,NULL
;********************************************

Why you can't open it may be that you set the second parameter of "CreateFile" other than "GENERIC_READ".

Have a good day!

Smallwaves.
Posted on 2002-02-23 23:53:43 by smallwaves
Can you really open this file. My first thought is that kernel32 holds it open with no sharing flags. Maybe I'm wrong but it seems very un-microsoft to allow r/w to the swap file from any prog.
Posted on 2002-02-24 00:10:09 by rdaneel
And If you have some simply way to open it.


:confused:


Have a good day!
Posted on 2002-02-24 02:38:34 by smallwaves
;******************************

Under Windows 98, the swap file can reside on a compressed drive if a protected-mode driver (that is, Drvspace.vxd) controls the compressed drive. DriveSpace marks the swap file as uncompressible andplaces the swap file as the last file in the sector heap places the swap file as the last file in the sector heap (to reduce the risk of fragmentation), allowing room for the swap file to grow.

;******************************

------------------From MSDN----------------------

if win386.swp is in driver c:\ ,Could you read it like What diskedit does?

hope it helps.
Posted on 2002-02-24 03:27:29 by smallwaves
Thanks for your suggestion smallwaves, I tested and still get the sharing violation error. I think maybe rdaneel is right :(

If anybody finds out different please let me know.

best regards,

czDrillard
Posted on 2002-02-24 13:30:11 by czDrillard
I also think you cannot access it because the only way defraggers can defrag it is to do it during the load phase on Windows, obviously before any locks are placed on it. But don't stop trying, not everything in the MS world is documented, and there may be a way to do it (but not well known).
Posted on 2002-02-24 14:20:33 by sluggy