Jump to content
Sign in to follow this  
Andreik

FSCTL_SET_SPARSE

Recommended Posts

Andreik

How can I translate this code in AutoIt. I know that is an API _WinAPI_CreateFile() and DeviceIoControl can be called from kernel32.dll but I cannot find this constant or what it is FSCTL_SET_SPARSE. Any help is welcome.

int _tmain(int argc, _TCHAR* argv[])
{
HANDLE h = CreateFile("Test.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);

DWORD dw;
DeviceIoControl(h, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL);

LONG lDist = 4095;
SetFilePointer(h, 0, &lDist, FILE_BEGIN);
SetEndOfFile(h);

CloseHandle(h);

return 0;
}
Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites
FuryCell

Not positive if this is what you need but after several google searches I found this page.

http://www.techreplies.com/development-resources-58/sparse-files-deviceiocontrol-379393/

Public Const FSCTL_SET_SPARSE = &H900C4

So in AutoIt I assume this would be

Const  $FSCTL_SET_SPARSE =0x900C4
Edited by FuryCell

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites
Andreik

^Thanks for answer. Can you translate DllCall function DeviceIoControl. I get an fatal error when I call it. Am I missing something?

Dim $TEMP
$RESULT = DllCall("kernel32.dll","int","DeviceIoControl","hwnd",$FILE,"dword",0x900C4,"ptr",0,"dword",0,"ptr",0,"dword",0,"dword",$TEMP,"ptr",0)

When the words fail... music speaks

Share this post


Link to post
Share on other sites
KaFu

_WinAPI_DeviceIoControl is part of Yashieds excellent WinAPIEx UDF.

Edit: Additionally take a look at this MSDN article for the dll structure definition expected by the function.

Edited by KaFu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.